home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / os2 / programm / 4455 < prev    next >
Encoding:
Internet Message Format  |  1992-08-26  |  2.2 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!rutgers!njitgw.njit.edu!hertz.njit.edu!dic5340
  2. From: dic5340@hertz.njit.edu (David Charlap)
  3. Newsgroups: comp.os.os2.programmer
  4. Subject: Re: DosReadQueue and Timeouts
  5. Message-ID: <1992Aug26.204450.18857@njitgw.njit.edu>
  6. Date: 26 Aug 92 20:44:50 GMT
  7. References: <meek.714371000@fizzy> <19920826.040756.330@almaden.ibm.com>
  8. Sender: news@njit.edu
  9. Organization: New Jersey Institute of Technology, Newark, N.J.
  10. Lines: 34
  11. Nntp-Posting-Host: hertz.njit.edu
  12.  
  13. In article <19920826.040756.330@almaden.ibm.com> peterf@vnet.ibm.com writes:
  14. >1. Create a semaphore (I use a RAM semaphore), and SET it.
  15. >
  16. >2. Create the queue.
  17. >
  18. >3. Do an initial read on the queue, with the NoWait argument = (CHAR)1,
  19. >   and supply the semaphore handle of your semaphore.
  20. >   Try to do this while the queue is empty. You will then get the return-
  21. >   code ERROR_QUE_EMPTY - your semaphore is now registered by the queue
  22. >   subsystem, and will be CLEARed when something arrives in your queue.
  23. >
  24. >4. You can now do a DosSemWait on your semaphore, and use the timeout
  25. >   value as you like.
  26. >
  27. >5. If you get NO_ERROR from DosSemWait, you have element(s) in the queue.
  28. >   SET the semaphore.  Read elements with the same NoWait and semaphore
  29. >   arguments as in 3.  The semaphore will not be registered again until
  30. >   you get ERROR_QUE_EMPTY from DosReadQueue.  You can now GOTO 4, and
  31. >   wait on the semaphore again.
  32. >
  33. >   If you get ERROR_SEM_TIMEOUT from DosSemWait you can do your house-
  34. >   keeping (or whatever). The semaphore will stay SET and registered in
  35. >   the queue subsystem, so you just have to go back to 4 when you're done.
  36.  
  37. You can start your housekeeping automatically and do your DosSemWait
  38. with no timeouts in a separate thread, if you want/need to get fancy.
  39. Of course, you may need new semaphores to keep the housekeeping from
  40. mucking up the incoming data from the other thread if the housekeeping
  41. is something like garbage collection.
  42. -- 
  43.    |)  David Charlap           "I don't even represent myself
  44.   /|_  dic5340@hertz.njit.edu   sometimes so NJIT is right out!.
  45.  ((|,)
  46.   ~|~  Hi! I am a .signature virus, copy me into your .signature file.
  47.