summaryrefslogtreecommitdiff
path: root/lib/thread
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-09-16 13:40:31 -0400
committerOri Bernstein <ori@eigenstate.org>2015-09-16 13:40:31 -0400
commit1edee0e32036f4d1cb23e94cab7b8f72f6ee9193 (patch)
tree4005fdde3a2e4de9a22b0ad53af2ea4d92bc2e29 /lib/thread
parent28c95a0761154c121b49e54912f0c45dc7dffec0 (diff)
downloadmc-1edee0e32036f4d1cb23e94cab7b8f72f6ee9193.tar.gz
Rename 'Sleep' to 'Lockedcontended'.
Clearer meaning.
Diffstat (limited to 'lib/thread')
-rw-r--r--lib/thread/mutex+linux.myr12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/thread/mutex+linux.myr b/lib/thread/mutex+linux.myr
index dc5175b..62aa88a 100644
--- a/lib/thread/mutex+linux.myr
+++ b/lib/thread/mutex+linux.myr
@@ -16,7 +16,7 @@ pkg thread =
const Unlocked = 0
const Locked = 1
-const Sleep = 2
+const Lockedcontended = 2
generic Zptr = 0 castto(@a#)
var nspin = 1 /* FIXME: pick a sane number, based on CPU count */
@@ -38,12 +38,12 @@ const mtxlock = {mtx
/* contended: we set the lock _state to sleep */
if c == Locked
- c = xchg(&mtx._state, Sleep)
+ c = xchg(&mtx._state, Lockedcontended)
;;
while c != Unlocked
- sys.futex(&mtx._state, sys.Futexwait | sys.Futexpriv, Sleep, Zptr, Zptr, 0)
- c = xchg(&mtx._state, 2)
+ sys.futex(&mtx._state, sys.Futexwait | sys.Futexpriv, Lockedcontended, Zptr, Zptr, 0)
+ c = xchg(&mtx._state, Lockedcontended)
;;
}
@@ -53,7 +53,7 @@ const mtxtrylock = {mtx
const mtxunlock = {mtx
/* uncontended sleep means we can just unlock and move on */
- if mtx._state == Sleep
+ if mtx._state == Lockedcontended
mtx._state = Unlocked
elif xchg(&mtx._state, Unlocked) == Locked
->
@@ -62,7 +62,7 @@ const mtxunlock = {mtx
for var i = 0; i < nspin; i++
if mtx._state != Unlocked
/* there might have been waiters, but we set the _state to unlocked */
- if xcas(&mtx._state, Locked, Sleep) == Sleep
+ if xcas(&mtx._state, Locked, Lockedcontended) == Contendedlock
->
;;
;;