Deleted Added
full compact
41c41
< * $FreeBSD: head/sys/kern/kern_lock.c 71320 2001-01-21 07:52:20Z jasone $
---
> * $FreeBSD: head/sys/kern/kern_lock.c 71576 2001-01-24 12:35:55Z jasone $
57,62d56
< #ifdef SIMPLELOCK_DEBUG
< #define COUNT(p, x) if (p) (p)->p_locks += (x)
< #else
< #define COUNT(p, x)
< #endif
<
140,142c134
< * This is the waitloop optimization, and note for this to work
< * simple_lock and simple_unlock should be subroutines to avoid
< * optimization troubles.
---
> * This is the waitloop optimization.
283d274
< COUNT(p, 1);
291d281
< COUNT(p, 1);
313d302
< COUNT(p, -1);
331d319
< COUNT(p, -1);
363d350
< COUNT(p, 1);
385d371
< COUNT(p, 1);
421d406
< COUNT(p, 1);
432,434d416
< if (lkp->lk_lockholder != LK_KERNPROC) {
< COUNT(p, -1);
< }
442c424
< } else if (lkp->lk_flags & LK_SHARE_NONZERO) {
---
> } else if (lkp->lk_flags & LK_SHARE_NONZERO)
444,445d425
< COUNT(p, -1);
< }
471d450
< COUNT(p, 1);
630,726d608
<
< #if defined(SIMPLELOCK_DEBUG) && (MAXCPU == 1 || defined(COMPILING_LINT))
< #include <sys/kernel.h>
< #include <sys/sysctl.h>
<
< static int lockpausetime = 0;
< SYSCTL_INT(_debug, OID_AUTO, lockpausetime, CTLFLAG_RW, &lockpausetime, 0, "");
<
< static int simplelockrecurse;
<
< /*
< * Simple lock functions so that the debugger can see from whence
< * they are being called.
< */
< void
< simple_lock_init(alp)
< struct simplelock *alp;
< {
<
< alp->lock_data = 0;
< }
<
< void
< _simple_lock(alp, id, l)
< struct simplelock *alp;
< const char *id;
< int l;
< {
<
< 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) {
< Debugger("simple_lock");
< /*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");
< }
< }
< alp->lock_data = 1;
< if (curproc)
< curproc->p_simple_locks++;
< }
<
< int
< _simple_lock_try(alp, id, l)
< struct simplelock *alp;
< const char *id;
< int l;
< {
<
< if (alp->lock_data)
< return (0);
< if (simplelockrecurse)
< return (1);
< alp->lock_data = 1;
< if (curproc)
< curproc->p_simple_locks++;
< return (1);
< }
<
< void
< _simple_unlock(alp, id, l)
< struct simplelock *alp;
< const char *id;
< int l;
< {
<
< 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) {
< Debugger("simple_unlock");
< /* 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");
< }
< }
< alp->lock_data = 0;
< if (curproc)
< curproc->p_simple_locks--;
< }
< #elif defined(SIMPLELOCK_DEBUG)
< #error "SIMPLELOCK_DEBUG is not compatible with SMP!"
< #endif /* SIMPLELOCK_DEBUG && MAXCPU == 1 */