sem_trylock(2) DG/UX 5.4 Rel. 2.01 sem_trylock(2)
NAME
sem_trylock - lock an available semaphore
SYNOPSIS
#include <semaphore.h>
int semtrylock (*sem)
semt *sem;
DESCRIPTION
Use semtrylock(2) to lock a semaphore, making it unavailable to
other processes: sem is a valid semaphore descriptor returned by a
prior seminit(2) call. Once locked, a semaphore stays locked until
unlocked with semunlock(2). Thus, if your process locks a semaphore
and then calls semdestroy(2), exit(2), or exec(2), the semaphore
(provided it still exists) remains locked.
If the semaphore is unavailable, semtrylock returns immediately with
an error. Otherwise, the semaphore is locked. For a blocking lock
operation (block until the semaphore is available, then lock it), use
semlock(2).
Locking a semaphore decrements its value specified with seminit(2)
and unlocking it increments the value. This call succeeds when the
semaphore's value is greater than 0, which defines availability.
Note
* This routine is based on POSIX realtime extension document P1003.4
draft 12. 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, semlock returns 0. If unsuccessful, it returns -1 and
sets ERRNO to one of the following:
EAGAIN The semaphore is already locked.
EFAULT Unable to access the internal structures.
EINVAL sem is invalid.
SEE ALSO
semdestroy(2), seminit(2), semlock(2), semunlink(2),
semunlock(2).
Licensed material--property of copyright holder(s) 1