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 );
hSemaphore
lReleaseCount
lpPreviousCount
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.
0
(zero)
Versions | Defined in | Include | Link to |
---|---|---|---|
INtime 3.0 | intime/rt/include/iwin32.h intime/rt/include/winbase.h |
iwin32.h windows.h |
iwin32.lib |
Notes
CreateSemaphore, iwin32 API, iwin32 Overview