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.
47 .Fn msleep "void *chan" "struct mtx *mtx" "int priority" "const char *wmesg" "int timo"
49 .Fn msleep_sbt "void *chan" "struct mtx *mtx" "int priority" \
50 "const char *wmesg" "sbintime_t sbt" "sbintime_t pr" "int flags"
52 .Fn msleep_spin "void *chan" "struct mtx *mtx" "const char *wmesg" "int timo"
54 .Fn msleep_spin_sbt "void *chan" "struct mtx *mtx" "const char *wmesg" \
55 "sbintime_t sbt" "sbintime_t pr" "int flags"
57 .Fn pause "const char *wmesg" "int timo"
59 .Fn pause_sbt "const char *wmesg" "sbintime_t sbt" "sbintime_t pr" \
62 .Fn tsleep "void *chan" "int priority" "const char *wmesg" "int timo"
64 .Fn tsleep_sbt "void *chan" "int priority" "const char *wmesg" \
65 "sbintime_t sbt" "sbintime_t pr" "int flags"
67 .Fn wakeup "void *chan"
69 .Fn wakeup_one "void *chan"
79 handle event-based thread blocking.
80 If a thread must wait for an
81 external event, it is put to sleep by
87 Threads may also wait using one of the locking primitive sleep routines
95 is an arbitrary address that uniquely identifies the event on which
96 the thread is being put to sleep.
97 All threads sleeping on a single
101 often called from inside an interrupt routine, to indicate that the
102 resource the thread was blocking on is available now.
106 specifies a new priority for the thread as well as some optional flags.
107 If the new priority is not 0,
108 then the thread will be made
109 runnable with the specified
113 should never be used, as it is for compatibility only.
114 A new priority of 0 means to use the thread's current priority when
115 it is made runnable again.
121 flag, pending signals are allowed to interrupt the sleep, otherwise
122 pending signals are ignored during the sleep.
125 is set and a signal becomes pending,
127 is returned if the current system call should be restarted if
130 is returned if the system call should be interrupted by the signal
136 is a string describing the sleep condition for tools like
138 Due to the limited space of those programs to display arbitrary strings,
139 this message should not be longer than 6 characters.
143 specifies a timeout for the sleep.
147 then the thread will sleep for at most
150 If the timeout expires,
151 then the sleep function will return
155 .Fn msleep_spin_sbt ,
163 It allows the caller to specify relative or absolute wakeup time with higher resolution
168 allows the caller to specify wanted absolute event precision.
171 allows the caller to pass additional
172 .Fn callout_reset_sbt
175 Several of the sleep functions including
178 and the locking primitive sleep routines specify an additional lock
180 The lock will be released before sleeping and reacquired
181 before the sleep routine returns.
187 the lock will not be reacquired before returning.
188 The lock is used to ensure that a condition can be checked atomically,
189 and that the current thread can be suspended without missing a
190 change to the condition, or an associated wakeup.
191 In addition, all of the sleep routines will fully drop the
195 while the thread is suspended and will reacquire the
197 mutex before the function returns.
200 mutex may be specified as the lock to drop.
201 In that case, however, the
205 To avoid lost wakeups,
206 either a lock should be used to protect against races,
207 or a timeout should be specified to place an upper bound on the delay due
212 function should only be invoked with a timeout of 0 when the
218 function requires that
220 reference a default, i.e. non-spin, mutex.
221 Its use is deprecated in favor of
223 which provides identical behavior.
227 function requires that
229 reference a spin mutex.
232 function does not accept a
234 parameter and thus does not support changing the current thread's priority,
238 or catching signals via the
244 function is a wrapper around
246 that suspends execution of the current thread for the indicated timeout.
247 The thread can not be awakened early by signals or calls to
254 function makes the first thread in the queue that is sleeping on the
258 This reduces the load when a large number of threads are sleeping on
259 the same address, but only one of them can actually do any useful work
262 Due to the way it works, the
264 function requires that only related threads sleep on a specific
267 It is the programmer's responsibility to choose a unique
272 function did not require this, though it was never good practice
273 for threads to share a
280 pay particular attention to ensure that no other threads wait on the
284 If the timeout given by
288 is based on an absolute real-time clock value,
289 then the thread should copy the global
293 member before reading the RTC.
294 If the real-time clock is adjusted, these functions will set
296 to zero and return zero.
297 The caller should reconsider its orientation with the new RTC value.
299 When awakened by a call to
303 if a signal is pending and
306 a non-zero error code is returned.
307 If the thread is awakened by a call to
315 and locking primitive sleep functions return 0.
316 Zero can also be returned when the real-time clock is adjusted;
319 Otherwise, a non-zero error code is returned.
324 and the locking primitive sleep functions will fail if:
329 flag was specified, a signal was caught, and the system call should be
334 flag was specified, a signal was caught, and the system call should be
336 .It Bq Er EWOULDBLOCK
337 A non-zero timeout was specified and the timeout expired.
355 They were probably also present in the preceding
358 They were the basic process synchronization model.
364 and added the parameters
370 function was removed in
390 This manual page was written by
391 .An J\(:org Wunsch Aq Mt joerg@FreeBSD.org .