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.
48 .Fn msleep "void *chan" "struct mtx *mtx" "int priority" "const char *wmesg" "int timo"
50 .Fn msleep_sbt "void *chan" "struct mtx *mtx" "int priority" \
51 "const char *wmesg" "sbintime_t sbt" "sbintime_t pr" "int flags"
53 .Fn msleep_spin "void *chan" "struct mtx *mtx" "const char *wmesg" "int timo"
55 .Fn msleep_spin_sbt "void *chan" "struct mtx *mtx" "const char *wmesg" \
56 "sbintime_t sbt" "sbintime_t pr" "int flags"
58 .Fn pause "const char *wmesg" "int timo"
60 .Fn pause_sig "const char *wmesg" "int timo"
62 .Fn pause_sbt "const char *wmesg" "sbintime_t sbt" "sbintime_t pr" \
65 .Fn tsleep "void *chan" "int priority" "const char *wmesg" "int timo"
67 .Fn tsleep_sbt "void *chan" "int priority" "const char *wmesg" \
68 "sbintime_t sbt" "sbintime_t pr" "int flags"
70 .Fn wakeup "void *chan"
72 .Fn wakeup_one "void *chan"
84 handle event-based thread blocking.
85 If a thread must wait for an
86 external event, it is put to sleep by
94 Threads may also wait using one of the locking primitive sleep routines
102 is an arbitrary address that uniquely identifies the event on which
103 the thread is being put to sleep.
104 All threads sleeping on a single
106 are woken up later by
108 often called from inside an interrupt routine, to indicate that the
109 resource the thread was blocking on is available now.
113 specifies a new priority for the thread as well as some optional flags.
114 If the new priority is not 0,
115 then the thread will be made
116 runnable with the specified
120 should never be used, as it is for compatibility only.
121 A new priority of 0 means to use the thread's current priority when
122 it is made runnable again.
128 flag, pending signals are allowed to interrupt the sleep, otherwise
129 pending signals are ignored during the sleep.
132 is set and a signal becomes pending,
134 is returned if the current system call should be restarted if
137 is returned if the system call should be interrupted by the signal
142 flag is specified in addition to
144 then the sleeping thread is not stopped when
147 or some other stop action occurs while it is sleeping.
148 Instead, it is woken up, with the assumption
149 that the stop will occur on reaching a stop
150 point when returning to usermode.
151 The flag should be used when the sleeping thread owns resources, for instance
152 vnode locks, that should be released in a timely fashion.
156 is a string describing the sleep condition for tools like
158 Due to the limited space of those programs to display arbitrary strings,
159 this message should not be longer than 6 characters.
163 specifies a timeout for the sleep.
167 then the thread will sleep for at most
170 If the timeout expires,
171 then the sleep function will return
175 .Fn msleep_spin_sbt ,
183 It allows the caller to specify relative or absolute wakeup time with higher resolution
188 allows the caller to specify wanted absolute event precision.
191 allows the caller to pass additional
192 .Fn callout_reset_sbt
195 Several of the sleep functions including
198 and the locking primitive sleep routines specify an additional lock
200 The lock will be released before sleeping and reacquired
201 before the sleep routine returns.
207 the lock will not be reacquired before returning.
208 The lock is used to ensure that a condition can be checked atomically,
209 and that the current thread can be suspended without missing a
210 change to the condition, or an associated wakeup.
211 In addition, all of the sleep routines will fully drop the
215 while the thread is suspended and will reacquire the
217 mutex before the function returns.
220 mutex may be specified as the lock to drop.
221 In that case, however, the
225 To avoid lost wakeups,
226 either a lock should be used to protect against races,
227 or a timeout should be specified to place an upper bound on the delay due
232 function should only be invoked with a timeout of 0 when the
238 function requires that
240 reference a default, i.e. non-spin, mutex.
241 Its use is deprecated in favor of
243 which provides identical behavior.
247 function requires that
249 reference a spin mutex.
252 function does not accept a
254 parameter and thus does not support changing the current thread's priority,
258 or catching signals via the
264 function is a wrapper around
266 that suspends execution of the current thread for the indicated timeout.
267 The thread can not be awakened early by signals or calls to
273 function is a variant of
275 which can be awakened early by signals.
279 function makes the first thread in the queue that is sleeping on the
283 This reduces the load when a large number of threads are sleeping on
284 the same address, but only one of them can actually do any useful work
287 Due to the way it works, the
289 function requires that only related threads sleep on a specific
292 It is the programmer's responsibility to choose a unique
297 function did not require this, though it was never good practice
298 for threads to share a
305 pay particular attention to ensure that no other threads wait on the
309 When awakened by a call to
313 if a signal is pending and
316 a non-zero error code is returned.
317 If the thread is awakened by a call to
325 and locking primitive sleep functions return 0.
326 Otherwise, a non-zero error code is returned.
331 and the locking primitive sleep functions will fail if:
336 flag was specified, a signal was caught, and the system call should be
341 flag was specified, a signal was caught, and the system call should be
343 .It Bq Er EWOULDBLOCK
344 A non-zero timeout was specified and the timeout expired.
362 They were probably also present in the preceding
365 They were the basic process synchronization model.
371 and added the parameters
377 function was removed in
401 This manual page was written by
402 .An J\(:org Wunsch Aq joerg@FreeBSD.org .