From cb3ba12b7ade7cd9a4e452341fe4ce9ff6feecaf Mon Sep 17 00:00:00 2001 From: Kirk McKusick Date: Thu, 11 May 1995 21:51:47 -0800 Subject: [PATCH] minor cleanups; non-inline version of simple locking functions for NCPUS == 1 SCCS-vsn: sys/kern/kern_lock.c 8.9 --- usr/src/sys/kern/kern_lock.c | 61 ++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 9 deletions(-) diff --git a/usr/src/sys/kern/kern_lock.c b/usr/src/sys/kern/kern_lock.c index eb40b8e251..542fd61d9b 100644 --- a/usr/src/sys/kern/kern_lock.c +++ b/usr/src/sys/kern/kern_lock.c @@ -8,7 +8,7 @@ * * %sccs.include.redist.c% * - * @(#)kern_lock.c 8.8 (Berkeley) %G% + * @(#)kern_lock.c 8.9 (Berkeley) %G% */ #include @@ -50,13 +50,6 @@ int lock_wait_time = 100; */ #define PAUSE(lkp, wanted) -/* - * Panic messages for inline expanded simple locks. - * Put text here to avoid hundreds of copies. - */ -const char *simple_lock_held = "simple_lock: lock held"; -const char *simple_lock_not_held = "simple_lock: lock not held"; - #endif /* NCPUS == 1 */ /* @@ -83,13 +76,14 @@ const char *simple_lock_not_held = "simple_lock: lock not held"; * Initialize a lock; required before use. */ void -lock_init(lkp, prio, wmesg, timo, flags) +lockinit(lkp, prio, wmesg, timo, flags) struct lock *lkp; int prio; char *wmesg; int timo; int flags; { + bzero(lkp, sizeof(struct lock)); simple_lock_init(&lkp->lk_interlock); lkp->lk_flags = flags & LK_EXTFLG_MASK; @@ -350,6 +344,10 @@ lockmgr(lkp, flags, interlkp, pid) return (error); } +/* + * Print out information about state of a lock. Used by VOP_PRINT + * routines to display ststus about contained locks. + */ lockmgr_printinfo(lkp) struct lock *lkp; { @@ -362,3 +360,48 @@ lockmgr_printinfo(lkp) if (lkp->lk_waitcount > 0) printf(" with %d pending", lkp->lk_waitcount); } + +#if defined(DEBUG) && NCPUS == 1 +/* + * Simple lock functions so that the debugger can see from whence + * they are being called. + */ +void +simple_lock_init(alp) + struct simple_lock *alp; +{ + + alp->lock_data = 0; +} + +void +simple_lock(alp) + __volatile struct simple_lock *alp; +{ + + if (alp->lock_data == 1) + panic("simple_lock: lock held"); + alp->lock_data = 1; +} + +int +simple_lock_try(alp) + __volatile struct simple_lock *alp; +{ + + if (alp->lock_data == 1) + panic("simple_lock: lock held"); + alp->lock_data = 1; + return (1); +} + +void +simple_unlock(alp) + __volatile struct simple_lock *alp; +{ + + if (alp->lock_data == 0) + panic("simple_lock: lock not held"); + alp->lock_data = 0; +} +#endif /* DEBUG && NCPUS == 1 */ -- 2.20.1