kern_synch.c (136152) | kern_synch.c (136445) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1990, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 21 unchanged lines hidden (view full) --- 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95 35 */ 36 37#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1982, 1986, 1990, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 21 unchanged lines hidden (view full) --- 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95 35 */ 36 37#include <sys/cdefs.h> |
38__FBSDID("$FreeBSD: head/sys/kern/kern_synch.c 136152 2004-10-05 18:51:11Z jhb $"); | 38__FBSDID("$FreeBSD: head/sys/kern/kern_synch.c 136445 2004-10-12 18:36:20Z jhb $"); |
39 40#include "opt_ktrace.h" 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/condvar.h> 45#include <sys/kdb.h> 46#include <sys/kernel.h> --- 70 unchanged lines hidden (view full) --- 117 */ 118int 119msleep(ident, mtx, priority, wmesg, timo) 120 void *ident; 121 struct mtx *mtx; 122 int priority, timo; 123 const char *wmesg; 124{ | 39 40#include "opt_ktrace.h" 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/condvar.h> 45#include <sys/kdb.h> 46#include <sys/kernel.h> --- 70 unchanged lines hidden (view full) --- 117 */ 118int 119msleep(ident, mtx, priority, wmesg, timo) 120 void *ident; 121 struct mtx *mtx; 122 int priority, timo; 123 const char *wmesg; 124{ |
125 struct sleepqueue *sq; | |
126 struct thread *td; 127 struct proc *p; 128 int catch, rval, sig, flags; 129 WITNESS_SAVE_DECL(mtx); 130 131 td = curthread; 132 p = td->td_proc; 133#ifdef KTRACE --- 26 unchanged lines hidden (view full) --- 160 /* 161 * If we are already on a sleep queue, then remove us from that 162 * sleep queue first. We have to do this to handle recursive 163 * sleeps. 164 */ 165 if (TD_ON_SLEEPQ(td)) 166 sleepq_remove(td, td->td_wchan); 167 | 125 struct thread *td; 126 struct proc *p; 127 int catch, rval, sig, flags; 128 WITNESS_SAVE_DECL(mtx); 129 130 td = curthread; 131 p = td->td_proc; 132#ifdef KTRACE --- 26 unchanged lines hidden (view full) --- 159 /* 160 * If we are already on a sleep queue, then remove us from that 161 * sleep queue first. We have to do this to handle recursive 162 * sleeps. 163 */ 164 if (TD_ON_SLEEPQ(td)) 165 sleepq_remove(td, td->td_wchan); 166 |
168 sq = sleepq_lookup(ident); | 167 sleepq_lock(ident); |
169 if (catch) { 170 /* 171 * Don't bother sleeping if we are exiting and not the exiting 172 * thread or if our thread is marked as interrupted. 173 */ 174 mtx_lock_spin(&sched_lock); 175 rval = thread_sleep_check(td); 176 mtx_unlock_spin(&sched_lock); --- 19 unchanged lines hidden (view full) --- 196 * stopped without resuming us. Thus, we must be ready for sleep 197 * when cursig() is called. If the wakeup happens while we're 198 * stopped, then td will no longer be on a sleep queue upon 199 * return from cursig(). 200 */ 201 flags = SLEEPQ_MSLEEP; 202 if (catch) 203 flags |= SLEEPQ_INTERRUPTIBLE; | 168 if (catch) { 169 /* 170 * Don't bother sleeping if we are exiting and not the exiting 171 * thread or if our thread is marked as interrupted. 172 */ 173 mtx_lock_spin(&sched_lock); 174 rval = thread_sleep_check(td); 175 mtx_unlock_spin(&sched_lock); --- 19 unchanged lines hidden (view full) --- 195 * stopped without resuming us. Thus, we must be ready for sleep 196 * when cursig() is called. If the wakeup happens while we're 197 * stopped, then td will no longer be on a sleep queue upon 198 * return from cursig(). 199 */ 200 flags = SLEEPQ_MSLEEP; 201 if (catch) 202 flags |= SLEEPQ_INTERRUPTIBLE; |
204 sleepq_add(sq, ident, mtx, wmesg, flags); | 203 sleepq_add(ident, mtx, wmesg, flags); |
205 if (timo) 206 sleepq_set_timeout(ident, timo); 207 if (catch) { 208 sig = sleepq_catch_signals(ident); 209 } else 210 sig = 0; 211 212 /* --- 32 unchanged lines hidden (view full) --- 245/* 246 * Make all threads sleeping on the specified identifier runnable. 247 */ 248void 249wakeup(ident) 250 register void *ident; 251{ 252 | 204 if (timo) 205 sleepq_set_timeout(ident, timo); 206 if (catch) { 207 sig = sleepq_catch_signals(ident); 208 } else 209 sig = 0; 210 211 /* --- 32 unchanged lines hidden (view full) --- 244/* 245 * Make all threads sleeping on the specified identifier runnable. 246 */ 247void 248wakeup(ident) 249 register void *ident; 250{ 251 |
252 sleepq_lock(ident); |
|
253 sleepq_broadcast(ident, SLEEPQ_MSLEEP, -1); 254} 255 256/* 257 * Make a thread sleeping on the specified identifier runnable. 258 * May wake more than one thread if a target thread is currently 259 * swapped out. 260 */ 261void 262wakeup_one(ident) 263 register void *ident; 264{ 265 | 253 sleepq_broadcast(ident, SLEEPQ_MSLEEP, -1); 254} 255 256/* 257 * Make a thread sleeping on the specified identifier runnable. 258 * May wake more than one thread if a target thread is currently 259 * swapped out. 260 */ 261void 262wakeup_one(ident) 263 register void *ident; 264{ 265 |
266 sleepq_lock(ident); |
|
266 sleepq_signal(ident, SLEEPQ_MSLEEP, -1); 267} 268 269/* 270 * The machine independent parts of context switching. 271 */ 272void 273mi_switch(int flags, struct thread *newtd) --- 196 unchanged lines hidden --- | 267 sleepq_signal(ident, SLEEPQ_MSLEEP, -1); 268} 269 270/* 271 * The machine independent parts of context switching. 272 */ 273void 274mi_switch(int flags, struct thread *newtd) --- 196 unchanged lines hidden --- |