summaryrefslogtreecommitdiff
path: root/hurd/mutex.h
diff options
context:
space:
mode:
authorneal <neal>2008-01-23 22:53:30 +0000
committerneal <neal>2008-01-23 22:53:30 +0000
commitb962fefe8733a2fd7911090b3e8565eff3469048 (patch)
tree5629246a5d61c8b134c4d0fe18d5e80d66936242 /hurd/mutex.h
parent6d56ee9424816a5739970eedfb7f87f030a110ad (diff)
2008-01-23 Neal H. Walfield <neal@gnu.org>
* mutex.h (ss_mutex_unlock): Correctly test whether there are waiters. * rmutex.h (ss_rmutex_lock): Save the value of LOCKP->COUNT before unlocking the LOCKP->LOCK. After unlocking, use the cached value. (ss_rmutex_unlock): Improve assert. Only clear LOCKP->OWNER and wake a waiter if LOCKP->COUNT drops to 0. (ss_rmutex_trylock): Correctly test whether we got LOCKP->LOCK.
Diffstat (limited to 'hurd/mutex.h')
-rw-r--r--hurd/mutex.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/hurd/mutex.h b/hurd/mutex.h
index 3e21eee..3f50934 100644
--- a/hurd/mutex.h
+++ b/hurd/mutex.h
@@ -89,8 +89,9 @@ ss_mutex_unlock (__const char *caller, int line, ss_mutex_t *lockp)
{
/* We rely on the knowledge that unlocked is 0, locked and no
waiters is 1 and locked with waiters is 2. Thus if *lockp is 1,
- an atomic dec yields 0 and we know that there are no waiters. */
- if (! atomic_decrement_and_test (lockp))
+ an atomic dec yields 1 (the old value) and we know that there are
+ no waiters. */
+ if (atomic_decrement_and_test (lockp) != _MUTEX_LOCKED)
/* There are waiters. */
{
*lockp = 0;