|__THRSLEEP(2)||System Calls Manual||__THRSLEEP(2)|
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.
__thrsleep() blocks the calling thread on the abstract “wait channel” identified by the id argument until another thread calls
__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
__thrsleep() will return immediately without blocking.
The lock argument, if not
NULL, points to a locked spinlock that will be
__thrsleep() atomically with respect to
__thrwakeup(), such that if another thread
locks the spinlock before calling
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
__thrsleep() will immediately return
EINTR without blocking. This provides a mechanism
for a signal handler to keep a call to
from blocking, even if the signal is delivered immediately before the
__thrwakeup() 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:
__thrsleep() may return one
of the following errors:
__thrwakeup() may return the following
__thrsleep() with the same id were found.
__thrwakeup() functions are specific to OpenBSD and should not be used in portable applications.
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 Ted Unangst <tedu@OpenBSD.org>. This manual page was written by Philip Guenther <guenther@OpenBSD.org>.
|April 24, 2018||OpenBSD-current|