projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix race condition in wakeupThreadOnCapability() (#2574)
[ghc-hetmet.git]
/
rts
/
Schedule.c
diff --git
a/rts/Schedule.c
b/rts/Schedule.c
index
94aac6c
..
f8a8748
100644
(file)
--- a/
rts/Schedule.c
+++ b/
rts/Schedule.c
@@
-1405,7
+1405,8
@@
scheduleDoGC (Capability *cap, Task *task USED_IF_THREADS, rtsBool force_major)
StgTSO *t;
rtsBool heap_census;
#ifdef THREADED_RTS
StgTSO *t;
rtsBool heap_census;
#ifdef THREADED_RTS
- static volatile StgWord waiting_for_gc;
+ /* extern static volatile StgWord waiting_for_gc;
+ lives inside capability.c */
rtsBool was_waiting;
nat i;
#endif
rtsBool was_waiting;
nat i;
#endif
@@
-1422,6
+1423,10
@@
scheduleDoGC (Capability *cap, Task *task USED_IF_THREADS, rtsBool force_major)
// the other tasks to sleep and stay asleep.
//
// the other tasks to sleep and stay asleep.
//
+ /* Other capabilities are prevented from running yet more Haskell
+ threads if waiting_for_gc is set. Tested inside
+ yieldCapability() and releaseCapability() in Capability.c */
+
was_waiting = cas(&waiting_for_gc, 0, 1);
if (was_waiting) {
do {
was_waiting = cas(&waiting_for_gc, 0, 1);
if (was_waiting) {
do {
@@
-1866,7
+1871,7
@@
scheduleThreadOn(Capability *cap, StgWord cpu USED_IF_THREADS, StgTSO *tso)
if (cpu == cap->no) {
appendToRunQueue(cap,tso);
} else {
if (cpu == cap->no) {
appendToRunQueue(cap,tso);
} else {
- migrateThreadToCapability_lock(&capabilities[cpu],tso);
+ wakeupThreadOnCapability(cap, &capabilities[cpu], tso);
}
#else
appendToRunQueue(cap,tso);
}
#else
appendToRunQueue(cap,tso);
@@
-2307,8
+2312,6
@@
checkBlackHoles (Capability *cap)
if (type != BLACKHOLE && type != CAF_BLACKHOLE) {
IF_DEBUG(sanity,checkTSO(t));
t = unblockOne(cap, t);
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 {
*prev = t;
any_woke_up = rtsTrue;
} else {