kern_synch.c (68808) | kern_synch.c (68862) |
---|---|
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. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95 | 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. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95 |
39 * $FreeBSD: head/sys/kern/kern_synch.c 68808 2000-11-16 02:16:44Z jhb $ | 39 * $FreeBSD: head/sys/kern/kern_synch.c 68862 2000-11-17 18:09:18Z jake $ |
40 */ 41 42#include "opt_ktrace.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/proc.h> 47#include <sys/ipl.h> --- 367 unchanged lines hidden (view full) --- 415 struct callout_handle thandle; 416 int rval = 0; 417 WITNESS_SAVE_DECL(mtx); 418 419#ifdef KTRACE 420 if (p && KTRPOINT(p, KTR_CSW)) 421 ktrcsw(p->p_tracep, 1, 0); 422#endif | 40 */ 41 42#include "opt_ktrace.h" 43 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/proc.h> 47#include <sys/ipl.h> --- 367 unchanged lines hidden (view full) --- 415 struct callout_handle thandle; 416 int rval = 0; 417 WITNESS_SAVE_DECL(mtx); 418 419#ifdef KTRACE 420 if (p && KTRPOINT(p, KTR_CSW)) 421 ktrcsw(p->p_tracep, 1, 0); 422#endif |
423 DROP_GIANT_NOSWITCH(); | |
424 WITNESS_SLEEP(0, mtx); 425 mtx_enter(&sched_lock, MTX_SPIN); | 423 WITNESS_SLEEP(0, mtx); 424 mtx_enter(&sched_lock, MTX_SPIN); |
425 DROP_GIANT_NOSWITCH(); |
|
426 427 if (mtx != NULL) { 428 mtx_assert(mtx, MA_OWNED | MA_NOTRECURSED); 429 WITNESS_SAVE(mtx, mtx); 430 mtx_exit(mtx, MTX_DEF | MTX_NOSWITCH); 431 if (priority & PDROP) 432 mtx = NULL; 433 } --- 22 unchanged lines hidden (view full) --- 456 457 p->p_wchan = ident; 458 p->p_wmesg = wmesg; 459 p->p_slptime = 0; 460 p->p_priority = priority & PRIMASK; 461 p->p_nativepri = p->p_priority; 462 CTR4(KTR_PROC, "msleep: proc %p (pid %d, %s), schedlock %p", 463 p, p->p_pid, p->p_comm, (void *) sched_lock.mtx_lock); | 426 427 if (mtx != NULL) { 428 mtx_assert(mtx, MA_OWNED | MA_NOTRECURSED); 429 WITNESS_SAVE(mtx, mtx); 430 mtx_exit(mtx, MTX_DEF | MTX_NOSWITCH); 431 if (priority & PDROP) 432 mtx = NULL; 433 } --- 22 unchanged lines hidden (view full) --- 456 457 p->p_wchan = ident; 458 p->p_wmesg = wmesg; 459 p->p_slptime = 0; 460 p->p_priority = priority & PRIMASK; 461 p->p_nativepri = p->p_priority; 462 CTR4(KTR_PROC, "msleep: proc %p (pid %d, %s), schedlock %p", 463 p, p->p_pid, p->p_comm, (void *) sched_lock.mtx_lock); |
464 TAILQ_INSERT_TAIL(&slpque[LOOKUP(ident)], p, p_procq); | 464 TAILQ_INSERT_TAIL(&slpque[LOOKUP(ident)], p, p_slpq); |
465 if (timo) 466 thandle = timeout(endtsleep, (void *)p, timo); 467 /* 468 * We put ourselves on the sleep queue and start our timeout 469 * before calling CURSIG, as we could stop there, and a wakeup 470 * or a SIGCONT (or both) could occur while we were stopped. 471 * A SIGCONT would cause us to be marked as SSLEEP 472 * without resuming us, thus we must be ready for sleep --- 105 unchanged lines hidden (view full) --- 578 unsleep(p); 579 580 if (ident) { 581 p->p_wchan = ident; 582 p->p_wmesg = wmesg; 583 p->p_slptime = 0; 584 p->p_asleep.as_priority = priority; 585 p->p_asleep.as_timo = timo; | 465 if (timo) 466 thandle = timeout(endtsleep, (void *)p, timo); 467 /* 468 * We put ourselves on the sleep queue and start our timeout 469 * before calling CURSIG, as we could stop there, and a wakeup 470 * or a SIGCONT (or both) could occur while we were stopped. 471 * A SIGCONT would cause us to be marked as SSLEEP 472 * without resuming us, thus we must be ready for sleep --- 105 unchanged lines hidden (view full) --- 578 unsleep(p); 579 580 if (ident) { 581 p->p_wchan = ident; 582 p->p_wmesg = wmesg; 583 p->p_slptime = 0; 584 p->p_asleep.as_priority = priority; 585 p->p_asleep.as_timo = timo; |
586 TAILQ_INSERT_TAIL(&slpque[LOOKUP(ident)], p, p_procq); | 586 TAILQ_INSERT_TAIL(&slpque[LOOKUP(ident)], p, p_slpq); |
587 } 588 589 mtx_exit(&sched_lock, MTX_SPIN); 590 splx(s); 591 592 return(0); 593} 594 --- 12 unchanged lines hidden (view full) --- 607int 608mawait(struct mtx *mtx, int priority, int timo) 609{ 610 struct proc *p = curproc; 611 int rval = 0; 612 int s; 613 WITNESS_SAVE_DECL(mtx); 614 | 587 } 588 589 mtx_exit(&sched_lock, MTX_SPIN); 590 splx(s); 591 592 return(0); 593} 594 --- 12 unchanged lines hidden (view full) --- 607int 608mawait(struct mtx *mtx, int priority, int timo) 609{ 610 struct proc *p = curproc; 611 int rval = 0; 612 int s; 613 WITNESS_SAVE_DECL(mtx); 614 |
615 DROP_GIANT_NOSWITCH(); | |
616 WITNESS_SLEEP(0, mtx); 617 mtx_enter(&sched_lock, MTX_SPIN); | 615 WITNESS_SLEEP(0, mtx); 616 mtx_enter(&sched_lock, MTX_SPIN); |
617 DROP_GIANT_NOSWITCH(); |
|
618 if (mtx != NULL) { 619 mtx_assert(mtx, MA_OWNED | MA_NOTRECURSED); 620 WITNESS_SAVE(mtx, mtx); 621 mtx_exit(mtx, MTX_DEF | MTX_NOSWITCH); 622 if (priority & PDROP) 623 mtx = NULL; 624 } 625 --- 147 unchanged lines hidden (view full) --- 773unsleep(p) 774 register struct proc *p; 775{ 776 int s; 777 778 s = splhigh(); 779 mtx_enter(&sched_lock, MTX_SPIN); 780 if (p->p_wchan) { | 618 if (mtx != NULL) { 619 mtx_assert(mtx, MA_OWNED | MA_NOTRECURSED); 620 WITNESS_SAVE(mtx, mtx); 621 mtx_exit(mtx, MTX_DEF | MTX_NOSWITCH); 622 if (priority & PDROP) 623 mtx = NULL; 624 } 625 --- 147 unchanged lines hidden (view full) --- 773unsleep(p) 774 register struct proc *p; 775{ 776 int s; 777 778 s = splhigh(); 779 mtx_enter(&sched_lock, MTX_SPIN); 780 if (p->p_wchan) { |
781 TAILQ_REMOVE(&slpque[LOOKUP(p->p_wchan)], p, p_procq); | 781 TAILQ_REMOVE(&slpque[LOOKUP(p->p_wchan)], p, p_slpq); |
782 p->p_wchan = 0; 783 } 784 mtx_exit(&sched_lock, MTX_SPIN); 785 splx(s); 786} 787 788/* 789 * Make all processes sleeping on the specified identifier runnable. --- 5 unchanged lines hidden (view full) --- 795 register struct slpquehead *qp; 796 register struct proc *p; 797 int s; 798 799 s = splhigh(); 800 mtx_enter(&sched_lock, MTX_SPIN); 801 qp = &slpque[LOOKUP(ident)]; 802restart: | 782 p->p_wchan = 0; 783 } 784 mtx_exit(&sched_lock, MTX_SPIN); 785 splx(s); 786} 787 788/* 789 * Make all processes sleeping on the specified identifier runnable. --- 5 unchanged lines hidden (view full) --- 795 register struct slpquehead *qp; 796 register struct proc *p; 797 int s; 798 799 s = splhigh(); 800 mtx_enter(&sched_lock, MTX_SPIN); 801 qp = &slpque[LOOKUP(ident)]; 802restart: |
803 TAILQ_FOREACH(p, qp, p_procq) { | 803 TAILQ_FOREACH(p, qp, p_slpq) { |
804 if (p->p_wchan == ident) { | 804 if (p->p_wchan == ident) { |
805 TAILQ_REMOVE(qp, p, p_procq); | 805 TAILQ_REMOVE(qp, p, p_slpq); |
806 p->p_wchan = 0; 807 if (p->p_stat == SSLEEP) { 808 /* OPTIMIZED EXPANSION OF setrunnable(p); */ 809 CTR4(KTR_PROC, 810 "wakeup: proc %p (pid %d, %s), schedlock %p", 811 p, p->p_pid, p->p_comm, (void *) sched_lock.mtx_lock); 812 if (p->p_slptime > 1) 813 updatepri(p); --- 27 unchanged lines hidden (view full) --- 841 register struct slpquehead *qp; 842 register struct proc *p; 843 int s; 844 845 s = splhigh(); 846 mtx_enter(&sched_lock, MTX_SPIN); 847 qp = &slpque[LOOKUP(ident)]; 848 | 806 p->p_wchan = 0; 807 if (p->p_stat == SSLEEP) { 808 /* OPTIMIZED EXPANSION OF setrunnable(p); */ 809 CTR4(KTR_PROC, 810 "wakeup: proc %p (pid %d, %s), schedlock %p", 811 p, p->p_pid, p->p_comm, (void *) sched_lock.mtx_lock); 812 if (p->p_slptime > 1) 813 updatepri(p); --- 27 unchanged lines hidden (view full) --- 841 register struct slpquehead *qp; 842 register struct proc *p; 843 int s; 844 845 s = splhigh(); 846 mtx_enter(&sched_lock, MTX_SPIN); 847 qp = &slpque[LOOKUP(ident)]; 848 |
849 TAILQ_FOREACH(p, qp, p_procq) { | 849 TAILQ_FOREACH(p, qp, p_slpq) { |
850 if (p->p_wchan == ident) { | 850 if (p->p_wchan == ident) { |
851 TAILQ_REMOVE(qp, p, p_procq); | 851 TAILQ_REMOVE(qp, p, p_slpq); |
852 p->p_wchan = 0; 853 if (p->p_stat == SSLEEP) { 854 /* OPTIMIZED EXPANSION OF setrunnable(p); */ 855 CTR4(KTR_PROC, 856 "wakeup1: proc %p (pid %d, %s), schedlock %p", 857 p, p->p_pid, p->p_comm, (void *) sched_lock.mtx_lock); 858 if (p->p_slptime > 1) 859 updatepri(p); --- 209 unchanged lines hidden --- | 852 p->p_wchan = 0; 853 if (p->p_stat == SSLEEP) { 854 /* OPTIMIZED EXPANSION OF setrunnable(p); */ 855 CTR4(KTR_PROC, 856 "wakeup1: proc %p (pid %d, %s), schedlock %p", 857 p, p->p_pid, p->p_comm, (void *) sched_lock.mtx_lock); 858 if (p->p_slptime > 1) 859 updatepri(p); --- 209 unchanged lines hidden --- |