summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-08-11 14:52:29 -0700
committerOri Bernstein <ori@eigenstate.org>2018-08-11 14:52:29 -0700
commit92847c0604e5f4fa790b1783595e8a503ad271be (patch)
tree64f8bf0bae5c90927af92bded53b0c4f2f739fc8
parent96641430b332facfacc55f6060d0425886f35697 (diff)
downloadmc-92847c0604e5f4fa790b1783595e8a503ad271be.tar.gz
Clean up the mutex code a bit more.HEADmaster
-rw-r--r--lib/thread/mutex+futex.myr8
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/thread/mutex+futex.myr b/lib/thread/mutex+futex.myr
index a99f0a8..a6453fa 100644
--- a/lib/thread/mutex+futex.myr
+++ b/lib/thread/mutex+futex.myr
@@ -67,13 +67,9 @@ const mtxunlock = {mtx
are uncontended by the xchg() call, then it's safe to simply return;
nobody was waiting for us.
*/
- if xcas(&mtx._state, Locked, Unlocked) == Locked
- -> void
+ if xchg(&mtx._state, Unlocked) == Contended
+ ftxwake(&mtx._state)
;;
-
- /* Contended case: set the state to unlocked and wake one thread */
- mtx._state = Unlocked
- ftxwake(&mtx._state)
}
const mtxcontended = {mtx