summaryrefslogtreecommitdiff
path: root/rts/Schedule.c
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2008-09-09 13:32:23 +0000
committerSimon Marlow <marlowsd@gmail.com>2008-09-09 13:32:23 +0000
commitd572aed64d9c40dcc38a49b09d18f301555e4efb (patch)
treef44fa2291ccc16f953a55470a375583d31a0d85f /rts/Schedule.c
parent4318aa600015f0d7b4d977cb67071f3f8e7c3b0b (diff)
downloadhaskell-d572aed64d9c40dcc38a49b09d18f301555e4efb.tar.gz
Fix race condition in wakeupThreadOnCapability() (#2574)
wakeupThreadOnCapbility() is used to signal another capability that there is a thread waiting to be added to its run queue. It adds the thread to the (locked) wakeup queue on the remote capability. In order to do this, it has to modify the TSO's link field, which has a write barrier. The write barrier might put the TSO on the mutable list, and the bug was that it was using the mutable list of the *target* capability, which we do not have exclusive access to. We should be using the current Capabilty's mutable list in this case.
Diffstat (limited to 'rts/Schedule.c')
-rw-r--r--rts/Schedule.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/rts/Schedule.c b/rts/Schedule.c
index 1b5afefc4f..f8a8748d8d 100644
--- a/rts/Schedule.c
+++ b/rts/Schedule.c
@@ -1871,7 +1871,7 @@ scheduleThreadOn(Capability *cap, StgWord cpu USED_IF_THREADS, StgTSO *tso)
if (cpu == cap->no) {
appendToRunQueue(cap,tso);
} else {
- migrateThreadToCapability_lock(&capabilities[cpu],tso);
+ wakeupThreadOnCapability(cap, &capabilities[cpu], tso);
}
#else
appendToRunQueue(cap,tso);
@@ -2312,8 +2312,6 @@ checkBlackHoles (Capability *cap)
if (type != BLACKHOLE && type != CAF_BLACKHOLE) {
IF_DEBUG(sanity,checkTSO(t));
t = unblockOne(cap, t);
- // urk, the threads migrate to the current capability
- // here, but we'd like to keep them on the original one.
*prev = t;
any_woke_up = rtsTrue;
} else {