diff options
author | Simon Marlow <marlowsd@gmail.com> | 2009-08-29 09:26:07 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2009-08-29 09:26:07 +0000 |
commit | 95ec750f94236c2ae127a147d7c9bebec036bcab (patch) | |
tree | e3049e465557b47389e9a297917b22e5dc49501f /rts | |
parent | 7d7c187b4a12f1bb350e85cdb0115e19537cc704 (diff) | |
download | haskell-95ec750f94236c2ae127a147d7c9bebec036bcab.tar.gz |
Maintain Task/Capability invariants in performPendingThrowTos
Fixes an ASSERTION failure with concprog001, -threaded -debug, +RTS -N2
Diffstat (limited to 'rts')
-rw-r--r-- | rts/Schedule.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/rts/Schedule.c b/rts/Schedule.c index e9d4327724..07af0bf3ea 100644 --- a/rts/Schedule.c +++ b/rts/Schedule.c @@ -2710,8 +2710,12 @@ performPendingThrowTos (StgTSO *threads) { StgTSO *tso, *next; Capability *cap; + Task *task, *saved_task;; step *step; + task = myTask(); + cap = task->cap; + for (tso = threads; tso != END_TSO_QUEUE; tso = next) { next = tso->global_link; @@ -2721,7 +2725,17 @@ performPendingThrowTos (StgTSO *threads) debugTrace(DEBUG_sched, "performing blocked throwTo to thread %lu", (unsigned long)tso->id); - cap = tso->cap; - maybePerformBlockedException(cap, tso); - } + // We must pretend this Capability belongs to the current Task + // for the time being, as invariants will be broken otherwise. + // In fact the current Task has exclusive access to the systme + // at this point, so this is just bookkeeping: + task->cap = tso->cap; + saved_task = tso->cap->running_task; + tso->cap->running_task = task; + maybePerformBlockedException(tso->cap, tso); + tso->cap->running_task = saved_task; + } + + // Restore our original Capability: + task->cap = cap; } |