DosSemWait
Bindings: C, MASM
This call blocks the current thread until an indicated semaphore clears,
but does not establish ownership of the semaphore.
DosSemWait (SemHandle, Timeout)
SemHandle (HSEM) - input
Reference to the semaphore.
For a system semaphore, this reference is the handle returned by a
DosCreateSem or DosOpenSem request that granted the requesting thread
access to the semaphore.
For a RAM semaphore, this reference is the address of a doubleword of
storage, allocated and initialized to zero by the application. This
sets the semaphore as unowned. Other than initializing the doubleword
to zero, an application must not modify a RAM semaphore directly;
instead it manipulates the semaphore with semaphore function calls.
Timeout (LONG) - input
Action taken by the requesting thread when the semaphore is set. The
values that can be specified are:
Value Definition
-1 The requesting thread waits indefinitely for the semaphore
to be cleared.
0 The requesting thread returns immediately.
> 0 The requesting thread waits the indicated number of
milliseconds for the semaphore to be cleared before resuming
execution.
rc (USHORT) - return
Return code descriptions are:
0 NO_ERROR
95 ERROR_INTERRUPT
121 ERROR_SEM_TIMEOUT
Remarks
The unblocking of a thread blocked by a DosSemWait is level-triggered.
That is, DosSemWait does not return until the semaphore remains clear
long enough for the affected thread to be redispatched and determine that
the semaphore is clear.
When an application needs to guarantee that another event has occurred
before continuing, it calls DosSemSetWait. DosSemSetWait combines the
functions of DosSemSet and DosSemWait and is used when there is a chance
the semaphore may be cleared by a thread that gets an intervening time
slice between calls by the current thread to set the semaphore and wait
until it is cleared. Issuing DosSemWait on a semaphore that has been
cleared has no effect; the thread continues to execute.
Created using Inf-PHP v.2 (c) 2003 Yuri Prokushev
Created using Inf-HTML v.0.9b (c) 1995 Peter Childs