kern_synch.c (73915) | kern_synch.c (74912) |
---|---|
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 73915 2001-03-07 03:01:53Z jhb $ | 39 * $FreeBSD: head/sys/kern/kern_synch.c 74912 2001-03-28 09:03:24Z jhb $ |
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> --- 329 unchanged lines hidden (view full) --- 377 int sig, catch = priority & PCATCH; 378 int rval = 0; 379 WITNESS_SAVE_DECL(mtx); 380 381#ifdef KTRACE 382 if (p && KTRPOINT(p, KTR_CSW)) 383 ktrcsw(p->p_tracep, 1, 0); 384#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> --- 329 unchanged lines hidden (view full) --- 377 int sig, catch = priority & PCATCH; 378 int rval = 0; 379 WITNESS_SAVE_DECL(mtx); 380 381#ifdef KTRACE 382 if (p && KTRPOINT(p, KTR_CSW)) 383 ktrcsw(p->p_tracep, 1, 0); 384#endif |
385 WITNESS_SLEEP(0, mtx); | 385 WITNESS_SLEEP(0, &mtx->mtx_object); |
386 mtx_lock_spin(&sched_lock); 387 if (cold || panicstr) { 388 /* 389 * After a panic, or during autoconfiguration, 390 * just give interrupts a chance, then just return; 391 * don't run any other procs or panic below, 392 * in case this is the idle process and already asleep. 393 */ 394 if (mtx != NULL && priority & PDROP) 395 mtx_unlock_flags(mtx, MTX_NOSWITCH); 396 mtx_unlock_spin(&sched_lock); 397 return (0); 398 } 399 400 DROP_GIANT_NOSWITCH(); 401 402 if (mtx != NULL) { 403 mtx_assert(mtx, MA_OWNED | MA_NOTRECURSED); | 386 mtx_lock_spin(&sched_lock); 387 if (cold || panicstr) { 388 /* 389 * After a panic, or during autoconfiguration, 390 * just give interrupts a chance, then just return; 391 * don't run any other procs or panic below, 392 * in case this is the idle process and already asleep. 393 */ 394 if (mtx != NULL && priority & PDROP) 395 mtx_unlock_flags(mtx, MTX_NOSWITCH); 396 mtx_unlock_spin(&sched_lock); 397 return (0); 398 } 399 400 DROP_GIANT_NOSWITCH(); 401 402 if (mtx != NULL) { 403 mtx_assert(mtx, MA_OWNED | MA_NOTRECURSED); |
404 WITNESS_SAVE(mtx, mtx); | 404 WITNESS_SAVE(&mtx->mtx_object, mtx); |
405 mtx_unlock_flags(mtx, MTX_NOSWITCH); 406 if (priority & PDROP) 407 mtx = NULL; 408 } 409 410 KASSERT(p != NULL, ("msleep1")); 411 KASSERT(ident != NULL && p->p_stat == SRUN, ("msleep")); 412 /* --- 80 unchanged lines hidden (view full) --- 493out: 494#ifdef KTRACE 495 if (KTRPOINT(p, KTR_CSW)) 496 ktrcsw(p->p_tracep, 0, 0); 497#endif 498 PICKUP_GIANT(); 499 if (mtx != NULL) { 500 mtx_lock(mtx); | 405 mtx_unlock_flags(mtx, MTX_NOSWITCH); 406 if (priority & PDROP) 407 mtx = NULL; 408 } 409 410 KASSERT(p != NULL, ("msleep1")); 411 KASSERT(ident != NULL && p->p_stat == SRUN, ("msleep")); 412 /* --- 80 unchanged lines hidden (view full) --- 493out: 494#ifdef KTRACE 495 if (KTRPOINT(p, KTR_CSW)) 496 ktrcsw(p->p_tracep, 0, 0); 497#endif 498 PICKUP_GIANT(); 499 if (mtx != NULL) { 500 mtx_lock(mtx); |
501 WITNESS_RESTORE(mtx, mtx); | 501 WITNESS_RESTORE(&mtx->mtx_object, mtx); |
502 } 503 return (rval); 504} 505 506/* 507 * asleep() - async sleep call. Place process on wait queue and return 508 * immediately without blocking. The process stays runnable until mawait() 509 * is called. If ident is NULL, remove process from wait queue if it is still --- 58 unchanged lines hidden (view full) --- 568int 569mawait(struct mtx *mtx, int priority, int timo) 570{ 571 struct proc *p = curproc; 572 int rval = 0; 573 int s; 574 WITNESS_SAVE_DECL(mtx); 575 | 502 } 503 return (rval); 504} 505 506/* 507 * asleep() - async sleep call. Place process on wait queue and return 508 * immediately without blocking. The process stays runnable until mawait() 509 * is called. If ident is NULL, remove process from wait queue if it is still --- 58 unchanged lines hidden (view full) --- 568int 569mawait(struct mtx *mtx, int priority, int timo) 570{ 571 struct proc *p = curproc; 572 int rval = 0; 573 int s; 574 WITNESS_SAVE_DECL(mtx); 575 |
576 WITNESS_SLEEP(0, mtx); | 576 WITNESS_SLEEP(0, &mtx->mtx_object); |
577 mtx_lock_spin(&sched_lock); 578 DROP_GIANT_NOSWITCH(); 579 if (mtx != NULL) { 580 mtx_assert(mtx, MA_OWNED | MA_NOTRECURSED); | 577 mtx_lock_spin(&sched_lock); 578 DROP_GIANT_NOSWITCH(); 579 if (mtx != NULL) { 580 mtx_assert(mtx, MA_OWNED | MA_NOTRECURSED); |
581 WITNESS_SAVE(mtx, mtx); | 581 WITNESS_SAVE(&mtx->mtx_object, mtx); |
582 mtx_unlock_flags(mtx, MTX_NOSWITCH); 583 if (priority & PDROP) 584 mtx = NULL; 585 } 586 587 s = splhigh(); 588 589 if (p->p_wchan != NULL) { --- 96 unchanged lines hidden (view full) --- 686 * is triggered as a safety. 687 */ 688 p->p_asleep.as_priority = 0; 689 690out: 691 PICKUP_GIANT(); 692 if (mtx != NULL) { 693 mtx_lock(mtx); | 582 mtx_unlock_flags(mtx, MTX_NOSWITCH); 583 if (priority & PDROP) 584 mtx = NULL; 585 } 586 587 s = splhigh(); 588 589 if (p->p_wchan != NULL) { --- 96 unchanged lines hidden (view full) --- 686 * is triggered as a safety. 687 */ 688 p->p_asleep.as_priority = 0; 689 690out: 691 PICKUP_GIANT(); 692 if (mtx != NULL) { 693 mtx_lock(mtx); |
694 WITNESS_RESTORE(mtx, mtx); | 694 WITNESS_RESTORE(&mtx->mtx_object, mtx); |
695 } 696 return (rval); 697} 698 699/* 700 * Implement timeout for msleep or asleep()/mawait() 701 * 702 * If process hasn't been awakened (wchan non-zero), --- 357 unchanged lines hidden --- | 695 } 696 return (rval); 697} 698 699/* 700 * Implement timeout for msleep or asleep()/mawait() 701 * 702 * If process hasn't been awakened (wchan non-zero), --- 357 unchanged lines hidden --- |