2 .\" Copyright (c) 1996 Joerg Wunsch
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
16 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
19 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 .Fn msleep "void *chan" "struct mtx *mtx" "int priority" "const char *wmesg" "int timo"
45 .Fn msleep_spin "void *chan" "struct mtx *mtx" "const char *wmesg" "int timo"
47 .Fn pause "const char *wmesg" "int timo"
49 .Fn tsleep "void *chan" "int priority" "const char *wmesg" "int timo"
51 .Fn wakeup "void *chan"
53 .Fn wakeup_one "void *chan"
63 handle event-based thread blocking.
64 If a thread must wait for an
65 external event, it is put to sleep by
71 Threads may also wait using one of the locking primitive sleep routines
79 is an arbitrary address that uniquely identifies the event on which
80 the thread is being put to sleep.
81 All threads sleeping on a single
85 often called from inside an interrupt routine, to indicate that the
86 resource the thread was blocking on is available now.
90 specifies a new priority for the thread as well as some optional flags.
91 If the new priority is not 0,
92 then the thread will be made
93 runnable with the specified
97 should never be used, as it is for compatibility only.
98 A new priority of 0 means to use the thread's current priority when
99 it is made runnable again.
104 flag, signals are checked before and after sleeping, otherwise signals are
108 is set and a signal needs to be delivered,
110 is returned if the current system call should be restarted if
113 is returned if the system call should be interrupted by the signal
119 is a string describing the sleep condition for tools like
121 Due to the limited space of those programs to display arbitrary strings,
122 this message should not be longer than 6 characters.
126 specifies a timeout for the sleep.
130 then the thread will sleep for at most
133 If the timeout expires,
134 then the sleep function will return
137 Several of the sleep functions including
140 and the locking primitive sleep routines specify an additional lock
142 The lock will be released before sleeping and reacquired
143 before the sleep routine returns.
149 the lock will not be reacquired before returning.
150 The lock is used to ensure that a condition can be checked atomically,
151 and that the current thread can be suspended without missing a
152 change to the condition, or an associated wakeup.
153 In addition, all of the sleep routines will fully drop the
157 while the thread is suspended and will reacquire the
159 mutex before the function returns.
162 mutex may be specified as the lock to drop.
163 In that case, however, the
167 To avoid lost wakeups,
168 either a lock should be used to protect against races,
169 or a timeout should be specified to place an upper bound on the delay due
174 function should only be invoked with a timeout of 0 when the
180 function requires that
182 reference a default, i.e. non-spin, mutex.
183 Its use is deprecated in favor of
185 which provides identical behavior.
189 function requires that
191 reference a spin mutex.
194 function does not accept a
196 parameter and thus does not support changing the current thread's priority,
200 or catching signals via the
206 function is a wrapper around
208 that suspends execution of the current thread for the indicated timeout.
209 The thread can not be awakened early by signals or calls to
216 function makes the first thread in the queue that is sleeping on the
220 This reduces the load when a large number of threads are sleeping on
221 the same address, but only one of them can actually do any useful work
224 Due to the way it works, the
226 function requires that only related threads sleep on a specific
229 It is the programmer's responsibility to choose a unique
234 function did not require this, though it was never good practice
235 for threads to share a
242 pay particular attention to ensure that no other threads wait on the
246 If the thread is awakened by a call to
254 and locking primitive sleep functions return 0.
255 Otherwise, a non-zero error code is returned.
260 and the locking primitive sleep functions will fail if:
265 flag was specified, a signal was caught, and the system call should be
270 flag was specified, a signal was caught, and the system call should be
272 .It Bq Er EWOULDBLOCK
273 A non-zero timeout was specified and the timeout expired.
290 They were probably also present in the preceding
293 They were the basic process synchronization model.
299 and added the parameters
305 function was removed in
325 This manual page was written by
326 .An J\(:org Wunsch Aq joerg@FreeBSD.org .