MSET(2) Domain/OS SysV MSET(2)
NAME
mset, mclear - set and clear semaphores for processes mapped in virtual
memory
SYNOPSIS
#include <sys/mman.h>
value = mset(sem, wait)
int value, wait;
semaphore *sem;
mclear(sem)
semaphore *sem;
DESCRIPTION
Domain/OS SysV provides primitives for synchronizing processes in virtual
memory using semaphores in shared memory. Semaphores must lie within a
MAP_SHARED region with at least the modes PROT_READ and PROT_WRITE (see
mmap(2)). The MAP_HASSEMAPHORE flag must have been specified when the
region was created.
mset indivisibly tests and sets the semaphore sem. sem must have been
initialized to zero before the first call to mset. If sem is 0 (false)
at the time of the call to mset, the process will acquire the lock and
mset returns true immediately.
The kernel does not check for deadlocks. mset does not block any signals
while the semaphore is held. The application must ensure that locked
semaphores are cleaned up correctly in the event the process terminates
abnormally. If a signal is caught while the process is blocked in mset,
mset is always restarted.
If sem is true at the time of the call to mset and wait is false, mset
returns false. If wait is true, the "want" flag is set and the test-
and-set is retried. If the lock is still unavailable, mset relinquishes
the processor until notified that it should retry.
mclear indivisibly tests and clears the semaphore sem . If the "want"
flag is false at the time of the call to mclear, mclear returns true
immediately. If the "want" flag is true at the time of the call to
mclear, it arranges for waiting processes to retry before returning.
NOTES
This implementation is based upon a proposal by McKusick and Karels, and
upon other sources. Its details may change in a future release.
SEE ALSO
McKusick, M.K. and Karels, M.J. A New Virtual Memory Implementation for
Berkeley UNIX. Berkeley, California: Department of Electrical
Engineering and Computer Science, University of California, 1986.
madvise(2), mmap(2), mprotect(2).