TSPutSemaphore()

Syntax

TSPutSemaphore(semaphore [, count])

Description

This command will put the semaphore back, increasing its availability. This then allows the semaphore to be available for threads which are trying to get it. This command works for both the simple semaphore type and the shared section of complex semaphores.

Warning: in the case of the shared section of complex semaphores, this involves an infinite wait. This should not normally cause your thread to stop unless you are trying to put back a shared availability while there is already an exclusive access in progress. Another reason to check that you successfully got access to a semaphore.

Paramaters:
semaphore.l - The handle of the semaphore which was created with TSCreateSemaphore()
count.l - Optional parameter. Wihtout it, the availability is always increased by one. When you specify this parameter, you can control how much the availability should be increased by. This value must be more than or equal to zero and less than or equal to the number of current accesses, or it will not be put back.

Return value:
The value returned by this command is the availability of the semaphore (simple or shared part of complex) when it is put back, or -1 if the command failed for some reason. Note, that may not be the current state by the time you check this value as other threads may have got or put back the semaphore since it was put back. Therefore the return value may or may not be of use, it depends what (if anything) you want to do with it.

Example:


See also:
TSCreateSemaphore() , TSGetSemaphore()

Supported OS

Windows

ThreadSync - Index