|TSLEEP(9)||Kernel Developer's Manual||TSLEEP(9)|
wakeup_one — process context
sleep and wakeup
priority, const char
*ident, struct mutex
*mtx, int priority,
const char *wmesg,
These functions implement voluntary context switching.
msleep() are used throughout the kernel whenever
processing in the current context cannot continue for any of the following
functions are used to notify sleeping processes of possible changes to the
condition that caused them to go to sleep. Typically, an awakened process
will -- after it has acquired a context again -- retry the action that
blocked its operation to see if the “blocking” condition has
function takes the following arguments:
wakeup() to get the process going again. ident should not be
PCATCHis OR'ed into priority the process checks for posted signals before and after sleeping.
p_wmesg) for user level utilities such as ps(1).
timo/hzseconds. If this amount of time elapses and no
wakeup(ident) has occurred, and no signal (if
PCATCHwas set) was posted,
tsleep() will return
function behaves just like
tsleep(), but takes an
PNORELOCKflag is set in the priority argument.
function will mark all processes which are currently sleeping on the
identifier ident as runnable. Eventually, each of the
processes will resume execution in the kernel context, causing a return from
tsleep(). Note that processes returning from sleep
should always re-evaluate the conditions that blocked them, since a call to
wakeup() merely signals a
change to the blocking conditions. For example, when two or more processes
are waiting for an exclusive lock, only one of them will succeed in
acquiring the lock when it is released. All others will have to go back to
sleep and wait for the next opportunity.
msleep() return 0 if they return as a result of a
wakeup(). If they return as a result of a signal,
the return value is
ERESTART if the signal has the
SA_RESTART property (see
EINTR otherwise. If they return as a result of a
timeout, the return value is
These functions are implemented in the file sys/kern/kern_synch.c.
|September 14, 2015||OpenBSD-5.9|