ref: 95ba2c2257e56e80fe01cfcce5b533e4b4e54e7b
parent: d3091cbc968337bdd47efe3bab7e752972cad726
author: Ori Bernstein <ori@eigenstate.org>
date: Wed Sep 16 15:07:32 EDT 2015
Unbreak mutex.
--- a/lib/thread/mutex+linux.myr
+++ b/lib/thread/mutex+linux.myr
@@ -63,7 +63,9 @@
are uncontended by the xchg() call, then it's safe to simply return;
nobody was waiting for us.
*/
- if mtx._state != Contended && xchg(&mtx._state, Unlocked) == Locked
+ if mtx._state == Contended
+ mtx._state = Unlocked
+ elif xchg(&mtx._state, Unlocked) == Locked
->
;;
@@ -74,7 +76,6 @@
so that if there are still waiters, the thread that took the lock takes
responsibility for unlocking.
*/
- mtx._state = Unlocked
for var i = 0; i < nspin; i++
if mtx._state != Unlocked
/*