diff options
Diffstat (limited to 'sys/kern/kern_rwlock.c')
-rw-r--r-- | sys/kern/kern_rwlock.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c index 0df33c9008b..9802a8323b5 100644 --- a/sys/kern/kern_rwlock.c +++ b/sys/kern/kern_rwlock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_rwlock.c,v 1.13 2007/05/13 04:52:32 tedu Exp $ */ +/* $OpenBSD: kern_rwlock.c,v 1.14 2009/08/13 21:22:29 blambert Exp $ */ /* * Copyright (c) 2002, 2003 Artur Grabowski <art@openbsd.org> @@ -197,6 +197,13 @@ retry: rw_enter_diag(rwl, flags); + if (((struct proc *)RW_PROC(rwl))->p_stat == SONPROC) { +printf("%p\n", (struct proc *)RW_PROC(rwl)); + while(((struct proc *)RW_PROC(rwl))->p_stat == SONPROC) + SPINLOCK_SPIN_HOOK; + goto retry; + } + if (flags & RW_NOSLEEP) return (EBUSY); @@ -248,3 +255,27 @@ rw_exit(struct rwlock *rwl) if (owner & RWLOCK_WAIT) wakeup(rwl); } + +void +rw_assert_wrlock(struct rwlock *rwl) +{ + if (!(rwl->rwl_owner & RWLOCK_WRLOCK)) + panic("%s: lock not held", rwl->rwl_name); + + if (RWLOCK_OWNER(rwl) != (struct proc *)((long)curproc & ~RWLOCK_MASK)) + panic("%s: lock not held by this process", rwl->rwl_name); +} + +void +rw_assert_rdlock(struct rwlock *rwl) +{ + if (!RWLOCK_OWNER(rwl) || (rwl->rwl_owner & RWLOCK_WRLOCK)) + panic("%s: lock not shared", rwl->rwl_name); +} + +void +rw_assert_unlocked(struct rwlock *rwl) +{ + if (rwl->rwl_owner != 0L) + panic("%s: lock held", rwl->rwl_name); +} |