X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FThreads.c;h=0dee734baa0edfc15903a437c5e191c266c33067;hb=fff1f6194c3c39de53cd645bda9865fb131b1c68;hp=e8a835bdaeb2bc08c98f429da4fcb74f004320b1;hpb=f4692220c7cbdadaa633f50eb2b30b59edb30183;p=ghc-hetmet.git diff --git a/rts/Threads.c b/rts/Threads.c index e8a835b..0dee734 100644 --- a/rts/Threads.c +++ b/rts/Threads.c @@ -217,7 +217,12 @@ removeThreadFromDeQueue (Capability *cap, void tryWakeupThread (Capability *cap, StgTSO *tso) { + tryWakeupThread_(cap, deRefTSO(tso)); +} +void +tryWakeupThread_ (Capability *cap, StgTSO *tso) +{ traceEventThreadWakeup (cap, tso, tso->cap->no); #ifdef THREADED_RTS @@ -279,6 +284,19 @@ unblock: // we'll block again. tso->why_blocked = NotBlocked; appendToRunQueue(cap,tso); + + // We used to set the context switch flag here, which would + // trigger a context switch a short time in the future (at the end + // of the current nursery block). The idea is that we have just + // woken up a thread, so we may need to load-balance and migrate + // threads to other CPUs. On the other hand, setting the context + // switch flag here unfairly penalises the current thread by + // yielding its time slice too early. + // + // The synthetic benchmark nofib/smp/chan can be used to show the + // difference quite clearly. + + // cap->context_switch = 1; } /* ---------------------------------------------------------------------------- @@ -291,7 +309,7 @@ migrateThread (Capability *from, StgTSO *tso, Capability *to) traceEventMigrateThread (from, tso, to->no); // ThreadMigrating tells the target cap that it needs to be added to // the run queue when it receives the MSG_TRY_WAKEUP. - tso->what_next = ThreadMigrating; + tso->why_blocked = ThreadMigrating; tso->cap = to; tryWakeupThread(from, tso); } @@ -383,6 +401,7 @@ updateThunk (Capability *cap, StgTSO *tso, StgClosure *thunk, StgClosure *val) i = thunk->header.info; if (i != &stg_BLACKHOLE_info && i != &stg_CAF_BLACKHOLE_info && + i != &__stg_EAGER_BLACKHOLE_info && i != &stg_WHITEHOLE_info) { updateWithIndirection(cap, thunk, val); return; @@ -486,8 +505,8 @@ printThreadBlockage(StgTSO *tso) case BlockedOnCCall: debugBelch("is blocked on an external call"); break; - case BlockedOnCCall_NoUnblockExc: - debugBelch("is blocked on an external call (exceptions were already blocked)"); + case BlockedOnCCall_Interruptible: + debugBelch("is blocked on an external call (but may be interrupted)"); break; case BlockedOnSTM: debugBelch("is blocked on an STM operation");