sem_trywait(2) DG/UX 5.4R3.00 sem_trywait(2)
NAME
sem_trywait - lock an available semaphore
SYNOPSIS
#include <semaphore.h>
int semtrywait (*sem)
semt *sem;
DESCRIPTION
Use semtrywait(2) to lock a semaphore which is currently available
(unlocked):
sem is a valid semaphore address returned by a prior
seminit(2) or semopen(2) call.
Locking a semaphore decrements its value, which is initially
specified with the seminit(2) or semopen(2) call. Unlocking a
semaphore increments the value.
This call locks the semaphore referenced by sem only if the semaphore
is currently not locked; that is, if the semaphore value is currently
positive. Otherwise, this call does not lock the semaphore. Once
locked, a semaphore stays locked until it is unlocked with
sempost(2). Thus, if your process locks a semaphore and then calls
semclose(2), exit(2), or exec(2), the semaphore (provided it still
exists) remains locked.
If the semaphore is unavailable, semtrywait returns immediately with
an error. For a blocking lock operation (block until the semaphore
is available, then lock it), use semwait(2).
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, semtrywait returns 0. If unsuccessful, it returns -1
and sets ERRNO to one of the following:
EAGAIN The semaphore is already locked, so it cannot be immediately
locked.
EINVAL sem is an invalid address.
EINVAL sem is invalid.
Licensed material--property of copyright holder(s) 1
sem_trywait(2) DG/UX 5.4R3.00 sem_trywait(2)
SEE ALSO
semdestroy(2), seminit(2), semclose(2), semopen(2),
semunlink(2), semwait(2), sempost(2), semgetvalue(2).
Licensed material--property of copyright holder(s) 2