USVSEMA(3P) USVSEMA(3P)
usvsema - release a semaphore
#include <ulocks.h>
int usvsema (usema_t *sema);
usvsema increments the count associated with sema. If there are any
processes queued waiting for the semaphore the first one is awakened.
usvsema uses the usema(7M) device to reactivate a suspended process. If
the process to be awoken is no longer alive, usvsema will automatically
attempt to awaken the next process waiting for the semaphore.
In order to use a semaphore, the caller must have joined the shared arena
out of which the semaphore is allocated (via usinit(3P)), and have a file
descriptor to a usema device to unsuspend any waiting processes. As a
convenience, usvsema will automatically do this for members of a share
group, or for related (via fork(2)) processes. This automatic facility
can generate the same errors as usinit(3P), and usopenpollsema(3P).
These errors will be passed back to the caller. If tracing is enabled
(see usinit(3P)) then any errors will cause a message to be printed to
stderr. To avoid these errors and therefore not need to check for errors
on every uvpsema call, have each process call usinit(3P) and each user of
a pollable semaphore call usopenpollsema(3P).
The following error can always occur:
[EBADF] The underlying file descriptor for the semaphore was
closed or re-used by the application.
uscpsema(3P), usinit(3P), usinitsema(3P), usnewsema(3P),
usnewpollsema(3P), usopenpollsema(3P), uspsema(3P), ustestsema(3P),
usema(7M).
Upon successful completion the semaphore has been released and a value of
0 is returned. On error, -1 is returned and errno is set to indicate the
error.
PPPPaaaaggggeeee 1111 [ Back ]
|