2 .\" Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice(s), this list of conditions and the following disclaimer as
9 .\" the first lines of this file unmodified other than the possible
10 .\" addition of one or more copyright notices.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice(s), 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 COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
16 .\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 .\" DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
19 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 .\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 .\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
39 .Nm cv_timedwait_sig ,
44 .Nd kernel condition variable
50 .Fn cv_init "struct cv *cvp" "const char *desc"
52 .Fn cv_destroy "struct cv *cvp"
54 .Fn cv_wait "struct cv *cvp" "struct mtx *mp"
56 .Fn cv_wait_sig "struct cv *cvp" "struct mtx *mp"
58 .Fn cv_timedwait "struct cv *cvp" "struct mtx *mp" "int timo"
60 .Fn cv_timedwait_sig "struct cv *cvp" "struct mtx *mp" "int timo"
62 .Fn cv_signal "struct cv *cvp"
64 .Fn cv_broadcast "struct cv *cvp"
66 .Fn cv_broadcastpri "struct cv *cvp" "int pri"
68 .Fn cv_wmesg "struct cv *cvp"
70 Condition variables are used in conjunction with mutexes to wait for conditions
72 Condition variables are created with
76 is a pointer to space for a
80 is a pointer to a null-terminated character string that describes the condition
82 Condition variables are destroyed with
84 Threads wait on condition variables by calling
89 .Fn cv_timedwait_sig .
90 Threads unblock waiters by calling
92 to unblock one waiter, or
96 to unblock all waiters.
97 In addition to waking waiters,
99 ensures that all of the waiters have a priority of at least
101 by raising the priority of any threads that do not.
103 returns the description string of
105 as set by the initial call to
115 .Fn cv_timedwait_sig .
116 When a thread waits on a condition,
118 is atomically released before the thread is blocked, then atomically reacquired
119 before the function call returns.
120 All waiters must pass the same
131 unblock, their calling threads are made runnable.
139 seconds before being unblocked and returning
141 otherwise, they return 0.
145 return prematurely with a value of
149 if a signal is caught, or 0 if signaled via
160 Otherwise, a non-zero error code is returned.
163 returns the description string that was passed to
172 An unmasked signal was caught.
174 A masked signal was caught.
182 .It Bq Er EWOULDBLOCK