int _lwp_sema_wait(lwp_sema_t *sema);
int _lwp_sema_init(lwp_sema_t *sema, int count);
int _lwp_sema_post(lwp_sema_t *sema);
Conceptually, a semaphore is an non-negative integer count that is atomically incremented and decremented. Typically this represents the number of resources available. _lwp_sema_init() initializes the count, _lwp_sema_post() atomically increments the count, and _lwp_sema_wait() waits for the count to become greater than zero and then atomically decrements it.
LWP semaphores must be initialized before use. _lwp_sema_init() initializes the count associated with the LWP semaphore pointed to by sema to count.
_lwp_sema_wait() blocks the calling LWP until the semaphore count becomes greater than zero and then atomically decrements it.
_lwp_sema_post() atomically increments the semaphore count. If there are any LWPs blocked on the semaphore, one is unblocked.
Zero is returned when successful. A non-zero value indicates an error.
If any of the following conditions are detected, _lwp_sema_init(), _lwp_sema_wait(), and _lwp_sema_post() fail and return the corresponding value:
Created by unroff & hp-tools. © by Hans-Peter Bischof. All Rights Reserved (1997).
Last modified 21/April/97