sem_getvalue(2) DG/UX R4.11MU05 sem_getvalue(2)
NAME
sem_getvalue - get the current value of a semaphore
SYNOPSIS
#include <semaphore.h>
int sem_getvalue (*sem, *semaphore_value)
sem_t *sem;
int *semaphore_value;
DESCRIPTION
Use sem_getvalue(2) to get the current value of a semaphore:
sem is a valid semaphore address returned by a prior sem_init(2)
or sem_open(2) call.
semaphore_value
is the location to update with the value of the semaphore.
sem_getvalue updates the location referenced by the semaphore_value
argument to have the value of the semaphore referenced by sem,
without affecting the state of the semaphore.
The semaphore_value returned is an actual semaphore value which
occurred at some unspecified time during the call, but may not be the
actual value of the semaphore when it is returned to the calling
process.
If sem is locked and unavailable to other processes, then the
semaphore_value returned by sem_getvalue is zero. If the semaphore
is unlocked and available to other processes (sem_trywait(2) will
successfully return), then the semaphore_value returned by
sem_getvalue is positive, and represents the number of successful
sem_trywait(2) calls that can be done on the semaphore.
Note
* This routine is based on POSIX realtime extension document P1003.4
draft 14. It is therefore subject to change.
* Compilation of a source file using this routine requires that
feature macro _POSIX4_DRAFT_SOURCE be defined. This feature macro
is not enabled by any other feature macro, nor does it enable any
other feature macro.
* The compiled routine must be linked to library librte.a.
RETURN VALUE
If successful, sem_getvalue returns 0. If unsuccessful, it returns -1
and sets ERRNO to one of the following:
EINVAL sem is invalid.
SEE ALSO
sem_destroy(2), sem_close(2), sem_init(2), sem_open(2),
sem_trywait(2), sem_wait(2), sem_unlink(2), sem_post(2).
Licensed material--property of copyright holder(s)