Index of Section 2 Manual Pages
| Interix / SUA | sem_timedwait.2 | Interix / SUA |
sem_timedwait(2) sem_timedwait(2)
sem_timedwait()
NAME
sem_timedwait() - lock a semaphore with expiration time
SYNOPSIS
#include
int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout);
DESCRIPTION
The sem_timedwait(2) locks the semaphore referenced by the sem argument.
If the semaphore is already locked, the calling thread or process is
blocked until the semaphore becomes available, as with the sem_wait(2)
function. If the semaphore cannot be locked because another process or
thread has the semaphore locked, the block ends when the system clock
reaches the time referenced by the abs_timeout argument, or if the time
has already passed when the call is made.
RETURN VALUES
On success, the function returns 0; otherwise, -1 is returned and errno is
set to an error code to indicate the error.
ERRORS
The sem_timedwait() function can fail for the following reasons:
[EDEADLK]
A deadlock condition occurred
[EINTR]
The function was interrupted by a signal.
[EINVAL]
The sem argument does not refer to a valid semaphore, or the process
or thread would have blocked and the abs_timeout argument specifies a
value in nanoseconds less than zero or greater than or equal to 1000
million.
[ETIMEDOUT]
A lock could not be obtained before the specified time was reached.
SEE ALSO
semctl(2)
semget(2)
semop(2)
sem_post(2)
sem_trywait(2)
sem_wait(2)
time(2)
USAGE NOTES
The sem_timedwait function is thread safe.
The sem_timedwait function is not async-signal safe.