MSEM_UNLOCK(3) SysV MSEM_UNLOCK(3)
NAME
msem_unlock - Unlock a semaphore
SYNOPSIS
#include <sys/mman.h>
int msem_unlock (sem, condition )
msemaphore *sem;
int condition;
DESCRIPTION
The msem_unlock function unlocks a binary semaphore.
The sem argument points to an msemaphore structure which specifies the
semaphore to be unlocked.
If the condition argument is 0 (zero), the semaphore is unlocked, whether
or not any other processes are currently attempting to lock it. If the
condition argument is MSEM_IF_WAITERS, and another process is waiting to
lock the semaphore or it cannot be reliably determined whether some
process is waiting to lock the semaphore, the semaphore is unlocked by
the calling process. If the condition argument is MSEM_IF_WAITERS, and
no process is waiting to lock the semaphore, the semaphore will not be
unlocked and an error will be returned.
All calls to the msem_lock(3) and msem_unlock functions by multiple
processes sharing a common msemaphore structure behave as if the calls
were serialized.
If the msemaphore structure contains any value not resulting from a call
to the msem_init(3) function followed by a (possibly empty) sequence of
calls to the msem_lock(3) and msem_unlock functions, the results are
undefined. The address of an msemaphore structure may be significant.
If the msemaphore structure contains any value copied from an msemaphore
structure at a different address, the result is undefined.
DIAGNOSTICS
On successful completion, the msem_unlock function returns 0 (zero). On
error, the msem_unlock function returns -1 and sets errno to indicate the
error.
ERRORS
msem_unlock fails if:
[EAGAIN] MSEM_IF_WAITERS was specified and there were no waiters.
[EINVAL] The sem argument points to an msemaphore structure which
specifies a semaphore which has been removed, or the
condition argument is invalid.
SEE ALSO
msem_init(3), msem_lock(3), msem_remove(3), <sys/mman.h>