sem_post

Releases the resource protected by the specified semaphore.

Library:LibC
Classification:POSIX
Service:Synchronization

Syntax

  #include <semaphore.h>
   
  int  sem_post  (
     sem_t   *sem );
  

Parameters

sem

(IN) Points to the semaphore to signal.

Return Values

If successful, returns 0 and increments the semaphore value. Otherwise, returns -1 and sets errno to one of the following values.

Decimal

Constant

Description

9

EINVAL

The sem parameter is invalid.

Remarks

The sem_post function increments the semaphore value. If a thread is waiting for the semaphore, it makes the blocked thread runnable. If multiple threads are blocked on the semaphore, no assumptions can be made about which of those threads might be unblocked.

See Also