🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer
Article #917

Re: DosReadQueue and Timeouts

#917
From: Peter Forsberg
Date: Wed, 26 Aug 1992 12:48
51 lines
2636 bytes
In <meek.714371000@fizzy> Lindsay Meek writes:
>Hello OS/2 people,
>   I'm trying to write a queue handler that incorperates the timeout
>feature available with semaphores i.e. DosSemWait(semaphore,timeout(ms))
>   I'm habving trouble getting DosReadQueue to suspend for a finite
>duration . Im using DosStartTimer and DosStopTimer and supplying the same
>semaphore as that used by the DosReadQueue function (in the hope that
>the Timer will signal on behalf of the DosReadQueue function). But it ain't
>working..
>   Has anybody had experience with this, or can suggest a method for
>doing it using the API calls?
>
>Thanks
>   Lindsay Meek (meek@fizzy.csu.murdoch.edu.au)
>

Lindsay,

I'm doing exactly the same thing that you want to do in the following way
(without using a timer):

1. Create a semaphore (I use a RAM semaphore), and SET it.

2. Create the queue.

3. Do an initial read on the queue, with the NoWait argument = (CHAR)1,
   and supply the semaphore handle of your semaphore.
   Try to do this while the queue is empty. You will then get the return-
   code ERROR_QUE_EMPTY - your semaphore is now registered by the queue
   subsystem, and will be CLEARed when something arrives in your queue.

4. You can now do a DosSemWait on your semaphore, and use the timeout
   value as you like.

5. If you get NO_ERROR from DosSemWait, you have element(s) in the queue.
   SET the semaphore.  Read elements with the same NoWait and semaphore
   arguments as in 3.  The semaphore will not be registered again until
   you get ERROR_QUE_EMPTY from DosReadQueue.  You can now GOTO 4, and
   wait on the semaphore again.

   If you get ERROR_SEM_TIMEOUT from DosSemWait you can do your house-
   keeping (or whatever). The semaphore will stay SET and registered in
   the queue subsystem, so you just have to go back to 4 when you're done.

Hope this helps  (if not I can send you a code fragment)

Peter
--
Peter Forsberg           E-mail:  peterf@vnet.ibm.com          (primary)
                                  d88-pfo@nada.kth.se        (alternate)
Disclaimer: This posting represents the poster's views, not those of IBM
Technical Details
Message-ID: <19920826.040756.330@almaden.ibm.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!vnet.ibm.com
References: <meek.714371000@fizzy>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!vnet.ibm.com
From: peterf@vnet.ibm.com (Peter Forsberg)
Message-ID: <19920826.040756.330@almaden.ibm.com>
Date: Wed, 26 Aug 92 12:48:36 SWE
Newsgroups: comp.os.os2.programmer
Subject: Re: DosReadQueue and Timeouts
Reply-To: peterf@vnet.ibm.com
Organization: IBM Corporation
Disclaimer: This posting represents the poster's views, not those of IBM
News-Software: UReply 3.0
References: <meek.714371000@fizzy>
Lines: 51