1
0
Files
irix-657m-src/eoe/man/man3c/sem_wait.3c
2022-09-29 17:59:04 +03:00

62 lines
1.8 KiB
Plaintext

'\"macro stdmacro
.Op c p a
.TH sem_wait 3C
.SH NAME
\f4sem_wait\f1, \f4sem_trywait\f1 \- acquire a posix named or unnamed semaphore
.SH SYNOPSIS
.nf
\f4#include <semaphore.h>\f1
.sp .6v
\f4int sem_wait(sem_t *\f2sem\fP);\f1
\f4int sem_trywait(sem_t *\f2sem\fP);\f1
.fi
.SH DESCRIPTION
.P
\f4sem_wait\fP atomically decrements the value of the semaphore located
at address \f2sem\fP. If the semaphore's value is less than zero after
the decrement, the calling process blocks on the semaphore. Otherwise,
the calling process continues without blocking.
.P
A process blocked on a semaphore remains blocked until either another
process posts the semaphore via \f4sem_post\fP, or the \f4sem_wait\fP
operation is interrupted by a signal.
.P
\f4sem_trywait\fP atomically decrements the semaphore \f4only\fP if the
resulting value is greater than or equal to zero. This way, the
\f4sem_trywait\fP function will never cause the calling process to block
on the semaphore.
.P
The address \f2sem\fP may reside anywhere in the calling processes
address space, but the process must have read and write access to \f2sem\fP.
.P
\f4sem_wait\f1 or \f4sem_trywait\f1 will fail if one or more of the
following are true:
.TP 12
[EAGAIN]
\f4sem_trywait\fP will generate this error if the semaphore was not
available.
.TP
[EDEADLK]
A deadlock condition was detected.
.TP
[EINVAL]
The semaphore located at address \f2sem\fP is not a valid posix named
or unnamed semaphore.
.TP
[EINTR]
The operation was interrupted by a signal.
.SH SEE ALSO
sem_init(3C),
sem_destroy(3C),
sem_getvalue(3C),
sem_post(3C),
sem_wait(3C),
sem_trywait(3C),
sem_open(3C),
sem_close(3C),
sem_unlink(3C),
.SH DIAGNOSTICS
Upon successful completion, a value of 0 is returned to the calling process.
Otherwise, a value of -1 is returned and \f4errno\fP is set to indicate
the error.