up | Inhaltsverzeichniss | Kommentar

Manual page for _lwp_sema_wait(2)

_lwp_sema_wait, _lwp_sema_init, _lwp_sema_post - semaphore operations

SYNOPSIS

#include <sys/lwp.h>

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);

DESCRIPTION

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.

RETURN VALUES

Zero is returned when successful. A non-zero value indicates an error.

ERRORS

If any of the following conditions are detected, _lwp_sema_init(), _lwp_sema_wait(), and _lwp_sema_post() fail and return the corresponding value:

EINVAL
sema points to an invalid semaphore.
EFAULT
sema points to an illegal address.
EINTR
_lwp_sema_wait() was interrupted by a signal or fork.2

SEE ALSO

fork.2


index | Inhaltsverzeichniss | Kommentar

Created by unroff & hp-tools. © by Hans-Peter Bischof. All Rights Reserved (1997).

Last modified 21/April/97