userspace thread sleep and
volatile void *id,
const struct timespec
*lock, const int
volatile void *id, int
__thrwakeup() functions provide thread sleep and
wakeup primitives with which synchronization primitives such as mutexes and
condition variables can be implemented.
blocks the calling thread on the abstract “wait channel”
identified by the id argument until another thread
__thrwakeup() with the same
id value. If the abstime
argument is not
NULL, then it specifies an absolute
time, measured against the clock_id clock, after which
__thrsleep() should time out and return. If the
specified time is in the past then
return immediately without blocking.
The lock argument, if not
NULL, points to a locked spinlock that will be
atomically with respect to calls to
such that if another thread locks the spinlock before calling
__thrwakeup() with the same
id, then the thread that called
__thrsleep() will be eligible for being woken up and
The abort argument, if not
NULL, points to an int that
will be examined after unlocking the spinlock pointed to by
lock and immediately before blocking. If that
int is non-zero then
will immediately return
EINTR without blocking. This
provides a mechanism for a signal handler to keep a call to
__thrsleep() from blocking, even if the signal is
delivered immediately before the call.
function unblocks one or more threads that are sleeping on the wait channel
identified by id. The number of threads unblocked is
specified by the count argument, except that if zero
is specified then all threads sleeping on that id are
__thrsleep() will return zero if woken by
a matching call to
__thrwakeup(), otherwise an error
number will be returned to indicate the error.
__thrwakeup() will return zero if at least
one matching call to
__thrsleep() was unblocked,
otherwise an error number will be returned to indicate the error.
__thrwakeup() will fail if:
- The ident argument is
__thrsleep() may return one
of the following errors:
- The time specified by the abstime and clock_id arguments was reached.
- A signal arrived or the abort argument pointed to a non-zero value.
- A signal arrived and SA_RESTART was set.
- The clock_id argument is not a valid clock_gettime(2) clock id or abstime specified a nanosecond value less than zero or greater than 1000 million.
__thrwakeup() may return the following
- No threads calling
__thrsleep() with the same id were found.
sigaction(2), pthread_cond_wait(3), pthread_mutex_lock(3), tsleep(9)
__thrwakeup() functions are specific to
OpenBSD and should not be used in portable
thrwakeup() syscalls appeared in
OpenBSD 3.9. The clock_id and
abstime arguments were added in
OpenBSD 4.9. The functions were renamed to
__thrwakeup() and the abort
argument was added in OpenBSD 5.1
thrwakeup() syscalls were created by
This manual page was written by Philip Guenther