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
40 .Nm cv_timedwait_sig ,
45 .Nd kernel condition variable
51 .Fn cv_init "struct cv *cvp" "const char *desc"
53 .Fn cv_destroy "struct cv *cvp"
55 .Fn cv_wait "struct cv *cvp" "lock"
57 .Fn cv_wait_sig "struct cv *cvp" "lock"
59 .Fn cv_wait_unlock "struct cv *cvp" "lock"
61 .Fn cv_timedwait "struct cv *cvp" "lock" "int timo"
63 .Fn cv_timedwait_sig "struct cv *cvp" "lock" "int timo"
65 .Fn cv_signal "struct cv *cvp"
67 .Fn cv_broadcast "struct cv *cvp"
69 .Fn cv_broadcastpri "struct cv *cvp" "int pri"
71 .Fn cv_wmesg "struct cv *cvp"
73 Condition variables are used in conjunction with mutexes to wait for conditions
75 Condition variables are created with
79 is a pointer to space for a
83 is a pointer to a null-terminated character string that describes the condition
85 Condition variables are destroyed with
87 Threads wait on condition variables by calling
93 .Fn cv_timedwait_sig .
94 Threads unblock waiters by calling
96 to unblock one waiter, or
100 to unblock all waiters.
101 In addition to waking waiters,
103 ensures that all of the waiters have a priority of at least
105 by raising the priority of any threads that do not.
107 returns the description string of
109 as set by the initial call to
114 argument is a pointer to either a
122 argument must be initialized with
134 .Fn cv_timedwait_sig .
135 When a thread waits on a condition,
137 is atomically released before the thread is blocked, then reacquired
138 before the function call returns.
139 In addition, the thread will fully drop the
143 while the it is suspended and will reacquire the
145 mutex before the function returns.
148 function does not reacquire the lock before returning.
151 mutex may be specified as
160 All waiters must pass the same
172 unblock, their calling threads are made runnable.
180 seconds before being unblocked and returning
182 otherwise, they return 0.
186 return prematurely with a value of
190 if a signal is caught, or 0 if signaled via
201 Otherwise, a non-zero error code is returned.
204 returns the description string that was passed to
213 A signal was caught and the system call should be interrupted.
215 A signal was caught and the system call should be restarted.
223 .It Bq Er EWOULDBLOCK