From 67812eacd74d5841e890b703d4ec2d5a76288830 Mon Sep 17 00:00:00 2001 From: Kirk McKusick Date: Sat, 26 Jun 1999 02:47:16 +0000 Subject: Convert buffer locking from using the B_BUSY and B_WANTED flags to using lockmgr locks. This commit should be functionally equivalent to the old semantics. That is, all buffer locking is done with LK_EXCLUSIVE requests. Changes to take advantage of LK_SHARED and LK_RECURSIVE will be done in future commits. --- sys/kern/kern_lock.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'sys/kern/kern_lock.c') diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index 3dde4b8c03e0..c7e9c84350e4 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -38,7 +38,7 @@ * SUCH DAMAGE. * * @(#)kern_lock.c 8.18 (Berkeley) 5/21/95 - * $Id: kern_lock.c,v 1.24 1999/03/12 03:09:29 julian Exp $ + * $Id: kern_lock.c,v 1.25 1999/03/15 05:11:27 julian Exp $ */ #include "opt_lint.h" @@ -384,7 +384,8 @@ debuglockmgr(lkp, flags, interlkp, p, name, file, line) case LK_RELEASE: if (lkp->lk_exclusivecount != 0) { #if !defined(MAX_PERF) - if (pid != lkp->lk_lockholder) + if (lkp->lk_lockholder != pid && + lkp->lk_lockholder != LK_KERNPROC) panic("lockmgr: pid %d, not %s %d unlocking", pid, "exclusive lock holder", lkp->lk_lockholder); @@ -517,6 +518,21 @@ lockstatus(lkp) return (lock_type); } +/* + * Determine the number of holders of a lock. + */ +int +lockcount(lkp) + struct lock *lkp; +{ + int count; + + simple_lock(&lkp->lk_interlock); + count = lkp->lk_exclusivecount + lkp->lk_sharecount; + simple_unlock(&lkp->lk_interlock); + return (count); +} + /* * Print out information about state of a lock. Used by VOP_PRINT * routines to display status about contained locks. -- cgit v1.2.3