1 .\" $NetBSD: ltsleep.9,v 1.11 2007/06/17 18:50:07 pooka Exp $
3 .\" Copyright (c) 1996, 2002, 2007 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Paul Kranenburg.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
37 .Nd process context sleep and wakeup
41 .Fn "ltsleep" "wchan_t ident" "pri_t priority" "const char *wmesg" "int timo" "volatile struct simplelock *slock"
43 .Fn "tsleep" "wchan_t ident" "pri_t priority" "const char *wmesg" "int timo"
45 .Fn "wakeup" "wchan_t ident"
47 .Em The interfaces described in this manual page are obsolete
48 .Em and will be removed from a future version of the system.
55 .Em manual pages for information on kernel synchronisation primitives.
57 These functions implement voluntary context switching.
61 are used throughout the kernel whenever processing in the current context
62 can not continue for any of the following reasons:
63 .Bl -bullet -offset indent
65 The current process needs to await the results of a pending I/O operation.
67 The current process needs resources
69 which are temporarily unavailable.
71 The current process wants access to data-structures which are locked by
77 is used to notify sleeping processes of possible changes to the condition
78 that caused them to go to sleep.
79 Typically, an awakened process will -- after it has acquired a context
80 again -- retry the action that blocked its operation to see if the
82 condition has cleared.
86 function takes the following arguments:
87 .Bl -tag -width priority
91 representing the resource for which the current process needs to wait.
92 This typically is the virtual address of some kernel data-structure related
93 to the resource for which the process is contending.
94 The same identifier must be used in a call to
96 to get the process going again.
101 The process priority to be used when the process is awakened and put on
102 the queue of runnable processes.
103 This mechanism is used to optimize
105 of processes executing in kernel mode.
110 the process checks for posted signals before and after sleeping.
116 is NOT re-locked after process resume.
118 A pointer to a character string indicating the reason a process is sleeping.
119 The kernel does not use the string, but makes it available
120 .Pq through the process structure field Li p_wmesg
121 for user level utilities such as
124 If non-zero, the process will sleep for at most
127 If this amount of time elapses and no
129 has occurred, and no signal
130 .Pq if Dv PCATCH No was set
138 interlock is unlocked once the scheduler lock is acquired.
144 the process is resumed from sleep.
145 This provides wakeup-before-sleep condition protection facility.
150 macro is functionally equivalent to:
151 .Bd -literal -offset indent
152 ltsleep(ident, priority, wmesg, timo, NULL)
157 function will mark all processes which are currently sleeping on the identifier
160 Eventually, each of the processes will resume execution in the kernel
161 context, causing a return from
163 Note that processes returning from sleep should always re-evaluate the
164 conditions that blocked them, since a call to
168 change to the blocking conditions.
169 For example, when two or more processes are waiting for an exclusive-access
172 only one of them will succeed in acquiring the lock when it is released.
173 All others will have to go back to sleep and wait for the next opportunity.
176 returns 0 if it returns as a result of a
180 returns as a result of a signal, the return value is
182 if the signal has the
185 .Pq see Xr sigaction 2 ,
191 returns because of a timeout it returns
201 The sleep/wakeup process synchronization mechanism is very old.
202 It appeared in a very early version of Unix.