From b265bae035bb8f63e5247eac7e9602915448412c Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Tue, 9 Nov 2004 17:41:30 +0000 Subject: [PATCH] Add lockcountnb() - a non-blocking version of lockcount() to be used only for assertions when the lock state is supposedly stable. --- sys/kern/kern_lock.c | 11 ++++++++++- sys/sys/lock.h | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index 63e81f3803..3a4e88c329 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -39,7 +39,7 @@ * * @(#)kern_lock.c 8.18 (Berkeley) 5/21/95 * $FreeBSD: src/sys/kern/kern_lock.c,v 1.31.2.3 2001/12/25 01:44:44 dillon Exp $ - * $DragonFly: src/sys/kern/kern_lock.c,v 1.11 2004/08/28 19:02:05 dillon Exp $ + * $DragonFly: src/sys/kern/kern_lock.c,v 1.12 2004/11/09 17:41:30 dillon Exp $ */ #include "opt_lint.h" @@ -525,6 +525,8 @@ lockstatus(struct lock *lkp, struct thread *td) /* * Determine the number of holders of a lock. + * + * The non-blocking version can usually be used for assertions. */ int lockcount(lkp) @@ -539,6 +541,13 @@ lockcount(lkp) return (count); } +int +lockcountnb(lkp) + struct lock *lkp; +{ + return (lkp->lk_exclusivecount + lkp->lk_sharecount); +} + /* * Print out information about state of a lock. Used by VOP_PRINT * routines to display status about contained locks. diff --git a/sys/sys/lock.h b/sys/sys/lock.h index b538524658..37b096b2d8 100644 --- a/sys/sys/lock.h +++ b/sys/sys/lock.h @@ -36,7 +36,7 @@ * * @(#)lock.h 8.12 (Berkeley) 5/19/95 * $FreeBSD: src/sys/sys/lock.h,v 1.17.2.3 2001/12/25 01:44:44 dillon Exp $ - * $DragonFly: src/sys/sys/lock.h,v 1.9 2004/08/28 19:02:07 dillon Exp $ + * $DragonFly: src/sys/sys/lock.h,v 1.10 2004/11/09 17:41:29 dillon Exp $ */ #ifndef _SYS_LOCK_H_ @@ -207,6 +207,7 @@ int lockmgr (struct lock *, u_int flags, void lockmgr_printinfo (struct lock *); int lockstatus (struct lock *, struct thread *); int lockcount (struct lock *); +int lockcountnb (struct lock *); #endif /* _KERNEL */ #endif /* _KERNEL || _KERNEL_STRUCTURES */ -- 2.41.0