X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/1c79356b52d46aa6b508fb032f5ae709b1f2897b..b36670cedae0009469e8ee117453de831de64a6b:/bsd/kern/kern_lock.c diff --git a/bsd/kern/kern_lock.c b/bsd/kern/kern_lock.c index 117407d6d..c69140fda 100644 --- a/bsd/kern/kern_lock.c +++ b/bsd/kern/kern_lock.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2001 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -60,7 +60,7 @@ */ #include -#include +#include #include #include #include @@ -91,11 +91,9 @@ int lock_wait_time = 100; if (lock_wait_time > 0) { \ int i; \ \ - simple_unlock(&lkp->lk_interlock); \ for (i = lock_wait_time; i > 0; i--) \ if (!(wanted)) \ break; \ - simple_lock(&lkp->lk_interlock); \ } \ if (!(wanted)) \ break; @@ -117,10 +115,8 @@ int lock_wait_time = 100; PAUSE(lkp, wanted); \ for (error = 0; wanted; ) { \ (lkp)->lk_waitcount++; \ - simple_unlock(&(lkp)->lk_interlock); \ error = tsleep((void *)lkp, (lkp)->lk_prio, \ (lkp)->lk_wmesg, (lkp)->lk_timo); \ - simple_lock(&(lkp)->lk_interlock); \ (lkp)->lk_waitcount--; \ if (error) \ break; \ @@ -137,13 +133,12 @@ void lockinit(lkp, prio, wmesg, timo, flags) struct lock__bsd__ *lkp; int prio; - char *wmesg; + const char *wmesg; int timo; int flags; { bzero(lkp, sizeof(struct lock__bsd__)); - simple_lock_init(&lkp->lk_interlock); lkp->lk_flags = flags & LK_EXTFLG_MASK; lkp->lk_prio = prio; lkp->lk_timo = timo; @@ -161,12 +156,10 @@ lockstatus(lkp) { int lock_type = 0; - simple_lock(&lkp->lk_interlock); if (lkp->lk_exclusivecount != 0) lock_type = LK_EXCLUSIVE; else if (lkp->lk_sharecount != 0) lock_type = LK_SHARED; - simple_unlock(&lkp->lk_interlock); return (lock_type); } @@ -181,7 +174,7 @@ int lockmgr(lkp, flags, interlkp, p) struct lock__bsd__ *lkp; u_int flags; - simple_lock_t interlkp; + void * interlkp; struct proc *p; { int error; @@ -194,9 +187,6 @@ lockmgr(lkp, flags, interlkp, p) pid = p->p_pid; else pid = LK_KERNPROC; - simple_lock(&lkp->lk_interlock); - if (flags & LK_INTERLOCK) - simple_unlock(interlkp); extflags = (flags | lkp->lk_flags) & LK_EXTFLG_MASK; #if 0 /* @@ -384,9 +374,11 @@ lockmgr(lkp, flags, interlkp, p) if (lkp->lk_exclusivecount != 0) { if (pid != lkp->lk_lockholder || lkp->lk_lockthread != self) - panic("lockmgr: pid %d, not %s %d unlocking", - pid, "exclusive lock holder", - lkp->lk_lockholder); + panic("lockmgr: pid %d, thread 0x%8x," + " not exclusive lock holder pid %d" + " thread 0x%8x unlocking, exclusive count %d", + pid, self, lkp->lk_lockholder, + lkp->lk_lockthread, lkp->lk_exclusivecount); lkp->lk_exclusivecount--; COUNT(p, -1); if (lkp->lk_exclusivecount == 0) { @@ -427,13 +419,11 @@ lockmgr(lkp, flags, interlkp, p) (LK_HAVE_EXCL | LK_WANT_EXCL | LK_WANT_UPGRADE)) || lkp->lk_sharecount != 0 || lkp->lk_waitcount != 0); ) { lkp->lk_flags |= LK_WAITDRAIN; - simple_unlock(&lkp->lk_interlock); if (error = tsleep((void *)&lkp->lk_flags, lkp->lk_prio, lkp->lk_wmesg, lkp->lk_timo)) return (error); if ((extflags) & LK_SLEEPFAIL) return (ENOLCK); - simple_lock(&lkp->lk_interlock); } lkp->lk_flags |= LK_DRAINING | LK_HAVE_EXCL; lkp->lk_lockholder = pid; @@ -443,7 +433,6 @@ lockmgr(lkp, flags, interlkp, p) break; default: - simple_unlock(&lkp->lk_interlock); panic("lockmgr: unknown locktype request %d", flags & LK_TYPE_MASK); /* NOTREACHED */ @@ -454,7 +443,6 @@ lockmgr(lkp, flags, interlkp, p) lkp->lk_flags &= ~LK_WAITDRAIN; wakeup((void *)&lkp->lk_flags); } - simple_unlock(&lkp->lk_interlock); return (error); } @@ -462,6 +450,7 @@ lockmgr(lkp, flags, interlkp, p) * Print out information about state of a lock. Used by VOP_PRINT * routines to display ststus about contained locks. */ +void lockmgr_printinfo(lkp) struct lock__bsd__ *lkp; {