X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FCapability.c;h=4d5748cec27274ed9f003461e03be8d2157a7cf4;hb=66579ff945831c5fc9a17c58c722ff01f2268d76;hp=1f1a1aea2a295a67fc09aa7c7219c96af93ca62c;hpb=d572aed64d9c40dcc38a49b09d18f301555e4efb;p=ghc-hetmet.git diff --git a/rts/Capability.c b/rts/Capability.c index 1f1a1ae..4d5748c 100644 --- a/rts/Capability.c +++ b/rts/Capability.c @@ -161,6 +161,7 @@ initCapability( Capability *cap, nat i ) cap->free_trec_chunks = END_STM_CHUNK_LIST; cap->free_trec_headers = NO_TREC; cap->transaction_tokens = 0; + cap->context_switch = 0; } /* --------------------------------------------------------------------------- @@ -218,6 +219,19 @@ initCapabilities( void ) } /* ---------------------------------------------------------------------------- + * setContextSwitches: cause all capabilities to context switch as + * soon as possible. + * ------------------------------------------------------------------------- */ + +void setContextSwitches(void) +{ + nat i; + for (i=0; i < n_capabilities; i++) { + capabilities[i].context_switch = 1; + } +} + +/* ---------------------------------------------------------------------------- * Give a Capability to a Task. The task must currently be sleeping * on its condition variable. * @@ -568,6 +582,7 @@ wakeupThreadOnCapability (Capability *my_cap, releaseCapability_(other_cap); } else { appendToWakeupQueue(my_cap,other_cap,tso); + other_cap->context_switch = 1; // someone is running on this Capability, so it cannot be // freed without first checking the wakeup queue (see // releaseCapability_).