X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FCapability.h;h=70d9ee9e8de418b4f9d3e1a6b17b47c025c00e74;hb=66579ff945831c5fc9a17c58c722ff01f2268d76;hp=a2551d0cc5025b7427879aad57bf7ba069f2c212;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/rts/Capability.h b/rts/Capability.h index a2551d0..70d9ee9 100644 --- a/rts/Capability.h +++ b/rts/Capability.h @@ -66,6 +66,10 @@ struct Capability_ { // each GC. bdescr **mut_lists; + // Context switch flag. We used to have one global flag, now one + // per capability. Locks required : none (conflicts are harmless) + int context_switch; + #if defined(THREADED_RTS) // Worker Tasks waiting in the wings. Singly-linked. Task *spare_workers; @@ -89,7 +93,8 @@ struct Capability_ { #endif // Per-capability STM-related data - StgTVarWaitQueue *free_tvar_wait_queues; + StgTVarWatchQueue *free_tvar_watch_queues; + StgInvariantCheckQueue *free_invariant_check_queues; StgTRecChunk *free_trec_chunks; StgTRecHeader *free_trec_headers; nat transaction_tokens; @@ -161,6 +166,9 @@ extern Capability *capabilities; // extern Capability *last_free_capability; +// GC indicator, in scope for the scheduler +extern volatile StgWord waiting_for_gc; + // Acquires a capability at a return point. If *cap is non-NULL, then // this is taken as a preference for the Capability we wish to // acquire. @@ -198,7 +206,8 @@ void waitForCapability (Task *task, Mutex *mutex, Capability **pCap); // Wakes up a thread on a Capability (probably a different Capability // from the one held by the current Task). // -void wakeupThreadOnCapability (Capability *cap, StgTSO *tso); +void wakeupThreadOnCapability (Capability *my_cap, Capability *other_cap, + StgTSO *tso); // Wakes up a worker thread on just one Capability, used when we // need to service some global event. @@ -212,7 +221,7 @@ void prodAllCapabilities (void); // Waits for a capability to drain of runnable threads and workers, // and then acquires it. Used at shutdown time. // -void shutdownCapability (Capability *cap, Task *task); +void shutdownCapability (Capability *cap, Task *task, rtsBool wait_foreign); // Attempt to gain control of a Capability if it is free. // @@ -227,6 +236,17 @@ extern void grabCapability (Capability **pCap); #endif /* !THREADED_RTS */ +// cause all capabilities to context switch as soon as possible. +void setContextSwitches(void); + +// Free a capability on exit +void freeCapability (Capability *cap); + +// FOr the GC: +void markSomeCapabilities (evac_fn evac, void *user, nat i0, nat delta); +void markCapabilities (evac_fn evac, void *user); +void traverseSparkQueues (evac_fn evac, void *user); + /* ----------------------------------------------------------------------------- * INLINE functions... private below here * -------------------------------------------------------------------------- */ @@ -236,6 +256,8 @@ recordMutableCap (StgClosure *p, Capability *cap, nat gen) { bdescr *bd; + // We must own this Capability in order to modify its mutable list. + ASSERT(cap->running_task == myTask()); bd = cap->mut_lists[gen]; if (bd->free >= bd->start + BLOCK_SIZE_W) { bdescr *new_bd;