Resources | Resources |




The ISemaphore interface provides an implementation of a counting semaphore, which is a counter for a set of available resources. The thread is blocked until the value of the semaphore is greater than zero.

Any thread wanting to acquire the semaphore needs to call ISemaphore_P(). P indicates a wait or blocking operation, which tells the thread to do nothing until a resource is available, whereupon it immediately claims one. A thread that has already acquired the semaphore can release it by invoking ISemaphore_V(). V is the inverse: it simply makes a resource available again after the process is finished using it. When ISemaphore_V() is invoked, one of the threads blocked on ISemaphore_P() is awakened and gets a chance to acquire the semaphore.

It is the application's responsibility to ensure that ISemaphore_P() and ISemaphore_V() calls match up. Otherwise, the result will be indeterminate. ISemaphore_V() always increments the count of the semaphore, so calling it erroneously sets the semaphore value to an unintended value. The number of threads that can simultaneously acquire a semaphore is equal to the initial value of the semaphore.

Required Files
Class ID(s)
Interface ID
platform\system\inc in the Brew MP SDK

For more information on ISemaphore, see the C/C++ API Reference.