summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>1998-12-28 19:13:05 +0000
committerArtur Grabowski <art@cvs.openbsd.org>1998-12-28 19:13:05 +0000
commit3bae67b49b885251f48e4fa79eb7bc06eec84a57 (patch)
tree6cda701abc605490352cfd3677cebcf51701a25e /sys
parent498d0d7fdc6d640c379cdfdb3a24d5764867fc71 (diff)
simple debugging for simple locks
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_lock.c68
-rw-r--r--sys/sys/simplelock.h16
2 files changed, 21 insertions, 63 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c
index de95a2a3dba..c8cdb419973 100644
--- a/sys/kern/kern_lock.c
+++ b/sys/kern/kern_lock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_lock.c,v 1.6 1998/11/10 22:20:36 art Exp $ */
+/* $OpenBSD: kern_lock.c,v 1.7 1998/12/28 19:13:04 art Exp $ */
/*
* Copyright (c) 1995
@@ -451,13 +451,8 @@ lockmgr_printinfo(lkp)
printf(" with %d pending", lkp->lk_waitcount);
}
-#if defined(DEBUG) && NCPUS == 1
-#include <sys/kernel.h>
-#include <vm/vm.h>
-#include <sys/sysctl.h>
-int lockpausetime = 0;
-struct ctldebug debug2 = { "lockpausetime", &lockpausetime };
-int simplelockrecurse;
+#if defined(SIMPLELOCK_DEBUG) && NCPUS == 1
+
/*
* Simple lock functions so that the debugger can see from whence
* they are being called.
@@ -476,28 +471,10 @@ _simple_lock(alp, id, l)
const char *id;
int l;
{
-#if 0
- if (simplelockrecurse)
- return;
- if (alp->lock_data == 1) {
- if (lockpausetime == -1)
- panic("%s:%d: simple_lock: lock held", id, l);
- printf("%s:%d: simple_lock: lock held\n", id, l);
- if (lockpausetime == 1) {
- BACKTRACE(curproc);
- } else if (lockpausetime > 1) {
- printf("%s:%d: simple_lock: lock held...", id, l);
- tsleep(&lockpausetime, PCATCH | PPAUSE, "slock",
- lockpausetime * hz);
- printf(" continuing\n");
- }
- }
+ if (alp->lock_data)
+ printf("%s:%d simple_lock: lock held...\n", id, l);
alp->lock_data = 1;
-
- if (curproc)
- curproc->p_simple_locks++;
-#endif
}
@@ -507,17 +484,10 @@ _simple_lock_try(alp, id, l)
const char *id;
int l;
{
-#if 0
if (alp->lock_data)
- return (0);
- if (simplelockrecurse)
- return (1);
- alp->lock_data = 1;
- if (curproc)
- curproc->p_simple_locks++;
-#endif
- return (1);
+ printf("%s:%d simple_lock: lock held...\n", id, l);
+ return alp->lock_data = 1;
}
void
@@ -526,25 +496,9 @@ _simple_unlock(alp, id, l)
const char *id;
int l;
{
-#if 0
- if (simplelockrecurse)
- return;
- if (alp->lock_data == 0) {
- if (lockpausetime == -1)
- panic("%s:%d: simple_unlock: lock not held", id, l);
- printf("%s:%d: simple_unlock: lock not held\n", id, l);
- if (lockpausetime == 1) {
- BACKTRACE(curproc);
- } else if (lockpausetime > 1) {
- printf("%s:%d: simple_unlock: lock not held...", id, l);
- tsleep(&lockpausetime, PCATCH | PPAUSE, "sunlock",
- lockpausetime * hz);
- printf(" continuing\n");
- }
- }
+
+ if (!alp->lock_data)
+ printf("%s:%d simple_unlock: lock not held...\n", id, l);
alp->lock_data = 0;
- if (curproc)
- curproc->p_simple_locks--;
-#endif
}
-#endif /* DEBUG && NCPUS == 1 */
+#endif /* SIMPLELOCK_DEBUG && NCPUS == 1 */
diff --git a/sys/sys/simplelock.h b/sys/sys/simplelock.h
index af3d60ac2cc..fd65047eb18 100644
--- a/sys/sys/simplelock.h
+++ b/sys/sys/simplelock.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: simplelock.h,v 1.5 1997/11/14 23:40:03 csapuntz Exp $ */
+/* $OpenBSD: simplelock.h,v 1.6 1998/12/28 19:13:01 art Exp $ */
#ifndef _SIMPLELOCK_H_
#define _SIMPLELOCK_H_
@@ -23,7 +23,11 @@ struct simplelock {
#if NCPUS == 1
-#if !defined(DEBUG)
+#if defined(DEBUG) && !defined(SIMPLELOCK_DEBUG)
+#define SIMPLELOCK_DEBUG
+#endif
+
+#if !defined(SIMPLELOCK_DEBUG)
#define simple_lock(alp)
#define simple_lock_try(alp) (1) /* always succeeds */
#define simple_unlock(alp)
@@ -40,15 +44,15 @@ simple_lock_init(lkp)
#else
-void _simple_unlock __P((__volatile struct simplelock *alp, const char *, int));
+void _simple_unlock __P((__volatile struct simplelock *, const char *, int));
#define simple_unlock(alp) _simple_unlock(alp, __FILE__, __LINE__)
-int _simple_lock_try __P((__volatile struct simplelock *alp, const char *, int));
+int _simple_lock_try __P((__volatile struct simplelock *, const char *, int));
#define simple_lock_try(alp) _simple_lock_try(alp, __FILE__, __LINE__)
-void _simple_lock __P((__volatile struct simplelock *alp, const char *, int));
+void _simple_lock __P((__volatile struct simplelock *, const char *, int));
#define simple_lock(alp) _simple_lock(alp, __FILE__, __LINE__)
void simple_lock_init __P((struct simplelock *alp));
-#endif /* !defined(DEBUG) */
+#endif /* !defined(SIMPLELOCK_DEBUG) */
#else /* NCPUS > 1 */