kern_condvar.c (177085) | kern_condvar.c (181334) |
---|---|
1/*- 2 * Copyright (c) 2000 Jake Burkholder <jake@freebsd.org>. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2000 Jake Burkholder <jake@freebsd.org>. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/kern/kern_condvar.c 177085 2008-03-12 06:31:06Z jeff $"); | 28__FBSDID("$FreeBSD: head/sys/kern/kern_condvar.c 181334 2008-08-05 20:02:31Z jhb $"); |
29 30#include "opt_ktrace.h" 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/lock.h> 35#include <sys/mutex.h> 36#include <sys/proc.h> --- 347 unchanged lines hidden (view full) --- 384 * the swapper if the process is not in memory, so that it can bring the 385 * sleeping process in. Note that this may also result in additional threads 386 * being made runnable. Should be called with the same mutex as was passed to 387 * cv_wait held. 388 */ 389void 390cv_signal(struct cv *cvp) 391{ | 29 30#include "opt_ktrace.h" 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/lock.h> 35#include <sys/mutex.h> 36#include <sys/proc.h> --- 347 unchanged lines hidden (view full) --- 384 * the swapper if the process is not in memory, so that it can bring the 385 * sleeping process in. Note that this may also result in additional threads 386 * being made runnable. Should be called with the same mutex as was passed to 387 * cv_wait held. 388 */ 389void 390cv_signal(struct cv *cvp) 391{ |
392 int wakeup_swapper; |
|
392 | 393 |
394 wakeup_swapper = 0; |
|
393 sleepq_lock(cvp); 394 if (cvp->cv_waiters > 0) { 395 cvp->cv_waiters--; | 395 sleepq_lock(cvp); 396 if (cvp->cv_waiters > 0) { 397 cvp->cv_waiters--; |
396 sleepq_signal(cvp, SLEEPQ_CONDVAR, 0, 0); | 398 wakeup_swapper = sleepq_signal(cvp, SLEEPQ_CONDVAR, 0, 0); |
397 } 398 sleepq_release(cvp); | 399 } 400 sleepq_release(cvp); |
401 if (wakeup_swapper) 402 kick_proc0(); |
|
399} 400 401/* 402 * Broadcast a signal to a condition variable. Wakes up all waiting threads. 403 * Should be called with the same mutex as was passed to cv_wait held. 404 */ 405void 406cv_broadcastpri(struct cv *cvp, int pri) 407{ | 403} 404 405/* 406 * Broadcast a signal to a condition variable. Wakes up all waiting threads. 407 * Should be called with the same mutex as was passed to cv_wait held. 408 */ 409void 410cv_broadcastpri(struct cv *cvp, int pri) 411{ |
412 int wakeup_swapper; 413 |
|
408 /* 409 * XXX sleepq_broadcast pri argument changed from -1 meaning 410 * no pri to 0 meaning no pri. 411 */ | 414 /* 415 * XXX sleepq_broadcast pri argument changed from -1 meaning 416 * no pri to 0 meaning no pri. 417 */ |
418 wakeup_swapper = 0; |
|
412 if (pri == -1) 413 pri = 0; 414 sleepq_lock(cvp); 415 if (cvp->cv_waiters > 0) { 416 cvp->cv_waiters = 0; | 419 if (pri == -1) 420 pri = 0; 421 sleepq_lock(cvp); 422 if (cvp->cv_waiters > 0) { 423 cvp->cv_waiters = 0; |
417 sleepq_broadcast(cvp, SLEEPQ_CONDVAR, pri, 0); | 424 wakeup_swapper = sleepq_broadcast(cvp, SLEEPQ_CONDVAR, pri, 0); |
418 } 419 sleepq_release(cvp); | 425 } 426 sleepq_release(cvp); |
427 if (wakeup_swapper) 428 kick_proc0(); |
|
420} | 429} |