X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FThreads.c;h=f6b1bac1a78d55696154937ff59498f170c7f9bd;hb=13b1fa907fd5d700167cc4da26668fb356d5ecfc;hp=25241c746a83e186423ed70b7a7d4d342f43e897;hpb=ef6e8211dee59eb7fa80a242391b89b52bd57f80;p=ghc-hetmet.git diff --git a/rts/Threads.c b/rts/Threads.c index 25241c7..f6b1bac 100644 --- a/rts/Threads.c +++ b/rts/Threads.c @@ -163,9 +163,11 @@ removeThreadFromQueue (Capability *cap, StgTSO **queue, StgTSO *tso) if (t == tso) { if (prev) { setTSOLink(cap,prev,t->_link); + t->_link = END_TSO_QUEUE; return rtsFalse; } else { *queue = t->_link; + t->_link = END_TSO_QUEUE; return rtsTrue; } } @@ -190,7 +192,8 @@ removeThreadFromDeQueue (Capability *cap, *head = t->_link; flag = rtsTrue; } - if (*tail == tso) { + t->_link = END_TSO_QUEUE; + if (*tail == tso) { if (prev) { *tail = prev; } else { @@ -284,6 +287,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; } /* ---------------------------------------------------------------------------- @@ -388,6 +404,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; @@ -491,8 +508,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");