summaryrefslogtreecommitdiff
path: root/lib/thread
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-07-28 00:03:47 -0700
committerOri Bernstein <ori@eigenstate.org>2018-07-28 00:15:33 -0700
commit38727e953df2c11f5600ea6f3142ec4366fce3cf (patch)
tree6780cd954e994981d8b3c228cd0e8d00125ff9a9 /lib/thread
parentc0c0b95a971cc5da839e7453ac3c7c069b5f20cd (diff)
downloadmc-38727e953df2c11f5600ea6f3142ec4366fce3cf.tar.gz
Allocate condvar waiters on heap.
It solves crashes on plan 9, because plan 9 keeps separate stacks in different procs.
Diffstat (limited to 'lib/thread')
-rw-r--r--lib/thread/condvar.myr14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/thread/condvar.myr b/lib/thread/condvar.myr
index 9649b92..4fde707 100644
--- a/lib/thread/condvar.myr
+++ b/lib/thread/condvar.myr
@@ -1,3 +1,5 @@
+use std
+
use "atomic"
use "common"
use "mutex"
@@ -35,23 +37,23 @@ const mkcond = {mtx
const condwait = {cond
var mtx = cond._mtx
var lock = &cond._lock
- var waiter = [.sem = mksem(0)]
+ var waiter = std.mk([.sem = mksem(0)])
mtxlock(lock)
match cond._waitq
| Zptr:
- waiter.prev = &waiter
- cond._waitq = &waiter
+ waiter.prev = waiter
+ cond._waitq = waiter
| q:
waiter.prev = q.prev
- waiter.prev.next = &waiter
- q.prev = &waiter
+ waiter.prev.next = waiter
+ q.prev = waiter
;;
mtxunlock(lock)
mtxunlock(mtx)
semwait(&waiter.sem)
-
+ std.free(waiter)
mtxlock(mtx)
}