X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FRaiseAsync.c;h=7abccde0a52a54aaeaf1b74e0413a08f37b00fc8;hb=c54980ff8b19f8f1e5ffb562f0477f7f674dabb6;hp=b94ccea283ce12fc5b1cfe8cd2a6164452b55a96;hpb=83d563cb9ede0ba792836e529b1e2929db926355;p=ghc-hetmet.git diff --git a/rts/RaiseAsync.c b/rts/RaiseAsync.c index b94ccea..7abccde 100644 --- a/rts/RaiseAsync.c +++ b/rts/RaiseAsync.c @@ -57,15 +57,9 @@ static void throwToSendMsg (Capability *cap USED_IF_THREADS, has been raised. -------------------------------------------------------------------------- */ -void -throwToSingleThreaded(Capability *cap, StgTSO *tso, StgClosure *exception) -{ - throwToSingleThreaded_(cap, tso, exception, rtsFalse); -} - -void -throwToSingleThreaded_(Capability *cap, StgTSO *tso, StgClosure *exception, - rtsBool stop_at_atomically) +static void +throwToSingleThreaded__ (Capability *cap, StgTSO *tso, StgClosure *exception, + rtsBool stop_at_atomically, StgUpdateFrame *stop_here) { tso = deRefTSO(tso); @@ -77,23 +71,26 @@ throwToSingleThreaded_(Capability *cap, StgTSO *tso, StgClosure *exception, // Remove it from any blocking queues removeFromQueues(cap,tso); - raiseAsync(cap, tso, exception, stop_at_atomically, NULL); + raiseAsync(cap, tso, exception, stop_at_atomically, stop_here); } void -suspendComputation(Capability *cap, StgTSO *tso, StgUpdateFrame *stop_here) +throwToSingleThreaded (Capability *cap, StgTSO *tso, StgClosure *exception) { - tso = deRefTSO(tso); - - // Thread already dead? - if (tso->what_next == ThreadComplete || tso->what_next == ThreadKilled) { - return; - } + throwToSingleThreaded__(cap, tso, exception, rtsFalse, NULL); +} - // Remove it from any blocking queues - removeFromQueues(cap,tso); +void +throwToSingleThreaded_ (Capability *cap, StgTSO *tso, StgClosure *exception, + rtsBool stop_at_atomically) +{ + throwToSingleThreaded__ (cap, tso, exception, stop_at_atomically, NULL); +} - raiseAsync(cap, tso, NULL, rtsFalse, stop_here); +void +suspendComputation (Capability *cap, StgTSO *tso, StgUpdateFrame *stop_here) +{ + throwToSingleThreaded__ (cap, tso, NULL, rtsFalse, stop_here); } /* ----------------------------------------------------------------------------- @@ -405,9 +402,12 @@ check_target: } } if (task != NULL) { - raiseAsync(cap, target, msg->exception, rtsFalse, NULL); - interruptWorkerTask(task); - return THROWTO_SUCCESS; + blockedThrowTo(cap, target, msg); + if (!((target->flags & TSO_BLOCKEX) && + ((target->flags & TSO_INTERRUPTIBLE) == 0))) { + interruptWorkerTask(task); + } + return THROWTO_BLOCKED; } else { debugTraceCap(DEBUG_sched, cap, "throwTo: could not find worker thread to kill"); } @@ -436,8 +436,20 @@ check_target: } #endif + case ThreadMigrating: + // if is is ThreadMigrating and tso->cap is ours, then it + // *must* be migrating *to* this capability. If it were + // migrating away from the capability, then tso->cap would + // point to the destination. + // + // There is a MSG_WAKEUP in the message queue for this thread, + // but we can just do it preemptively: + tryWakeupThread(cap, target); + // and now retry, the thread should be runnable. + goto retry; + default: - barf("throwTo: unrecognised why_blocked value"); + barf("throwTo: unrecognised why_blocked (%d)", target->why_blocked); } barf("throwTo"); }