INtime SDK Help
ReleaseSemaphore, RtReleaseSemaphore (iwin32)
INtime SDK v7 > About INtime > Alternate APIs > iwin32 API > iwin32 API > ReleaseSemaphore, RtReleaseSemaphore (iwin32)

Increases the specified semaphore object's count by a specified amount.

BOOLEAN ReleaseSemaphore(
    HANDLE hSemaphore,
    LONG lReleaseCount,
    LPLONG lpPreviousCount

BOOLEAN RtReleaseSemaphore(
    HANDLE hSemaphore,
    LONG lReleaseCount,
    LPLONG lpPreviousCount


Handle to the semaphore object. CreateSemaphore returns this handle.
The amount by which the semaphore object's current count increases. The value must be greater than zero. If the specified amount causes the semaphore count to exceed the maximum count specified when the semaphore was created, the count does not change and the function returns FALSE.
Long pointer to a 32-bit variable to receive the semaphore's previous count. If the previous count is not required, this parameter can be NULL.


The state of a semaphore object is signaled when its count exceeds zero and nonsignaled when its count equals zero. The process that calls CreateSemaphore specifies the semaphore's initial count. Each time a waiting thread is released because of the semaphore's signaled state, the semaphore's count decreases by one.

Typically, an application uses a semaphore to limit the number of threads using a resource. Before a thread uses the resource, it specifies the semaphore handle in a call to a wait function. When the wait function returns, it decreases the semaphore's count by one. When the thread finishes using the resource, it calls ReleaseSemaphore to increase the semaphore's count by one.

Another use of ReleaseSemaphore is during an application's initialization. The application can create a semaphore with an initial count of zero. This sets the semaphore's state to nonsignaled and blocks all threads from accessing the protected resource. When the application finishes its initialization, it uses ReleaseSemaphore to increase the count to its maximum value to permit normal access to the protected resource.

RtReleaseSemaphore can also be used from a Windows application to release a unit to an iwin32 semaphore.

Return Values

0 (zero)
Failure. For extended error information, see GetLastError


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


See Also

CreateSemaphore, iwin32 API, iwin32 Overview