|This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.|
Increment a semaphore
#include <semaphore.h> int sem_post( sem_t * sem );
- A pointer to the sem_t object for the semaphore whose value you want to increment.
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The sem_post() function increments the semaphore referenced by the sem argument. If any processes are currently blocked waiting for the semaphore, then one of these processes will return successfully from its call to sem_wait.
The process to be unblocked is determined in accordance with the scheduling policies in effect for the blocked processes. The highest priority waiting process is unblocked, and if there is more than one highest priority process blocked waiting for the semaphore, then the highest priority process that has been waiting the longest is unblocked.
The sem_post() function is reentrant with respect to signals, and can be called from a signal handler.
- An error occurred (errno is set).
- Invalid semaphore descriptor sem.
- The sem_post() function isn't supported.