sem_lock(2) DG/UX 5.4 Rel. 2.01 sem_lock(2)
NAME
sem_lock - lock a semaphore
SYNOPSIS
#include <semaphore.h>
int semlock (*sem)
semt *sem;
DESCRIPTION
Use semlock(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 continues to exist) remains locked.
If a semaphore is unavailable, semlock blocks until receiving a
signal, or until the semaphore becomes available. For a non-blocking
lock operation (return immediately with an error if the semaphore is
unavailable, otherwise lock it), use semtrylock(2).
Locking a semaphore decrements its value specified with seminit(2)
and unlocking it increments the value. This call blocks on a 0 or
negative value, which defines unavailability.
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:
EFAULT *sem is an invalid address.
EINTR Woken up by a signal rather than semaphore acquired.
EINVAL sem is invalid.
ENOSPC sem is unavailable and there is insufficient memory for
semlock(2) to block.
SEE ALSO
semdestroy(2), seminit(2), semtrylock(2), semunlink(2),
semunlock(2).
Licensed material--property of copyright holder(s) 1