INtime SDK Help
INtime SDK v7.1 > About INtime > INtime Kernel > Semaphores > knWaitForRtSemaphore

Requests a unit from the specified low-level semaphore.

BOOLEAN knWaitForRtSemaphore(
    KNHANDLE hSemaphore,    // handle for low-level semaphore
    DWORD dwKernelTicks     // the number of kernel clock intervals to wait


Handle for a low-level semaphore object.
Maximum number of Low-level Ticks which the calling thread is willing to wait for a unit. The length of this interval is configurable and its value may obtained from the SYSINFO structure which is read using CopyRtSystemInfo. The US_TO_KTICKS macro may be used to convert a value in microseconds to a system timer tick count using the information supplied in this structure.
Literal Meaning
KN_DONT_WAIT The thread does not wait at all.
KN_WAIT_FOREVER The thread waits indefinitely.
UINT_32 value The thread waits for the specified number of low-level ticks.


If the semaphore currently contains units, the number of units is reduced by 1 and the thread proceeds. If the semaphore has no units and the thread is willing to wait, the thread is put to sleep and placed into the semaphore's thread queue. The thread will be awakened by one of these events:

Note:   This is a blocking call; do not use it in an interrupt handler.

Return Values

Failure. To determine the status, call GetLastRtError.


The thread received the requested unit.
The time limit expired.
The semaphore was deleted while the thread was waiting.
Note:   Delete semaphores only after a thread begins waiting. This call cannot return control to the calling thread if its corresponding semaphore is already deleted.


Versions Defined in Include Link to
INtime 3.0 intime/rt/include/rtbase.h rt.h rt.lib

See Also

Semaphore system calls, CopyRtSystemInfo, knReleaseRtSemaphore