psema(D3X)psema(D3X)NAMEpsema - perform a "P" or wait semaphore operation
SYNOPSIS
#include "sys/types.h"
#include "sys/param.h"
#include "sys/sema.h"
psema(sema_t *semap, int flags);
DESCRIPTIONpsema performs a "P" semaphore operation on the given semaphore. The
value associated with the semaphore is decremented by 1. If the
semaphore value then becomes less than 0, the process goes to sleep and
gives up the CPU.
Use semap to pass psema a pointer to the semaphore you want to decrement.
Use flags to specify whether you want the process to be able to be woken
by a signal if it ends up going to sleep. A flag value of (flags &
PMASK) > PZERO will make the process interruptible, otherwise it is not.
The required symbolic constants are defined in param.h. If the process
is awakened by a signal, then the semaphore value is incremented and is
allowed to continue.
To initialize and allocate a semaphore, call initnsema or
initnsema_mutex.
Return Values
psema returns -1 if a breakable sleep is interrupted by a signal.
Otherwise psema returns 0.
Note
psema may cause the calling process to sleep; it must not be called from
within an interrupt procedure.
SEE ALSOsleep(D3), SLEEP_LOCK(D3)
Page 1