diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2014-07-09 13:32:01 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2014-07-09 13:32:01 +0000 |
commit | 61e233e8b12ea608fee9fb782af219307334dfa5 (patch) | |
tree | 6021d6aac7ec30cb28b787c40fd40971cbc342d9 /sys/kern | |
parent | db16be9113fcacedacce719c862e50f0f8916157 (diff) |
Teach rw_status() and rrw_status() to return LK_EXCLOTHER if it's write
locked by a different thread. Teach lockstatus() to return LK_EXCLUSIVE
if an exclusive lock is held by some other thread.
ok beck@ tedu@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_lock.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_rwlock.c | 10 |
2 files changed, 10 insertions, 4 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index cef4c7c7664..946fd17e3b3 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_lock.c,v 1.43 2014/01/21 01:48:44 tedu Exp $ */ +/* $OpenBSD: kern_lock.c,v 1.44 2014/07/09 13:32:00 guenther Exp $ */ /* * Copyright (c) 1995 @@ -64,6 +64,8 @@ lockstatus(struct lock *lkp) switch (rrw_status(&lkp->lk_lck)) { case RW_WRITE: return (LK_EXCLUSIVE); + case RW_WRITE_OTHER: + return (LK_EXCLOTHER); case RW_READ: return (LK_SHARED); case 0: diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c index a472b616400..e1def9e874d 100644 --- a/sys/kern/kern_rwlock.c +++ b/sys/kern/kern_rwlock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_rwlock.c,v 1.21 2014/01/21 01:48:44 tedu Exp $ */ +/* $OpenBSD: kern_rwlock.c,v 1.22 2014/07/09 13:32:00 guenther Exp $ */ /* * Copyright (c) 2002, 2003 Artur Grabowski <art@openbsd.org> @@ -256,8 +256,12 @@ rw_exit(struct rwlock *rwl) int rw_status(struct rwlock *rwl) { - if (rwl->rwl_owner & RWLOCK_WRLOCK) - return RW_WRITE; + if (rwl->rwl_owner & RWLOCK_WRLOCK) { + if (RW_PROC(curproc) == RW_PROC(rwl->rwl_owner)) + return RW_WRITE; + else + return RW_WRITE_OTHER; + } if (rwl->rwl_owner) return RW_READ; return (0); |