INtime SDK Help
RtReleaseSemaphore (iwin32x)
INtime SDK v7.1 > About INtime > Alternate APIs > iwin32 API > iwin32x API > RtReleaseSemaphore (iwin32x)

Increases the count of the specified semaphore object by a specified amount.

BOOLEAN RtReleaseSemaphore(
    HANDLE hSemaphore,
    LONG lReleaseCount,
    LPLONG lpPreviousCount
);

Parameters

hSemaphore
Handle to the semaphore object. RtCreateSemaphore returns this handle.
lReleaseCount
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.
lpPreviousCount
Long pointer to a 32-bit variable to receive the previous count for the semaphore. This parameter can be NULL if the previous count is not required.

Remarks

The state of a semaphore object is signaled when its count exceeds zero and nonsignaled when its count equals zero. The process that calls RtCreateSemaphore 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 RtCreateSemaphore to increase the semaphore's count by one.

Another use of RtCreateSemaphore 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

Non-zero
Success.
0 (zero)
Failure. For extended error information, see the Windows' GetLastError function.

Requirements

Versions Defined in Include Link to
INtime 3.0 intime/nt/include/iwin32x.h iwin32x.h iwin32x.lib

Notes

See Also

RtCreateSemaphore, iwin32x API, iwin32 Overview