X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=rts%2FCapability.h;h=d380af9cff5d3a952feebd7bfe85dcf08ceeeab7;hp=d8eba0d733f17b4c5334e5eb5f99a5a511c5295d;hb=b2524b3960999fffdb3767900f58825903f6560f;hpb=f4692220c7cbdadaa633f50eb2b30b59edb30183 diff --git a/rts/Capability.h b/rts/Capability.h index d8eba0d..d380af9 100644 --- a/rts/Capability.h +++ b/rts/Capability.h @@ -4,6 +4,9 @@ * * Capabilities * + * For details on the high-level design, see + * http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts/Scheduler + * * A Capability holds all the state an OS thread/task needs to run * Haskell code: its STG registers, a pointer to its TSO, a nursery * etc. During STG execution, a pointer to the Capabilitity is kept in @@ -22,7 +25,7 @@ #include "Task.h" #include "Sparks.h" -BEGIN_RTS_PRIVATE +#include "BeginPrivate.h" struct Capability_ { // State required by the STG virtual machine when running Haskell @@ -76,6 +79,7 @@ struct Capability_ { #if defined(THREADED_RTS) // Worker Tasks waiting in the wings. Singly-linked. Task *spare_workers; + nat n_spare_workers; // count of above // This lock protects running_task, returning_tasks_{hd,tl}, wakeup_queue. Mutex lock; @@ -95,8 +99,10 @@ struct Capability_ { // Stats on spark creation/conversion nat sparks_created; + nat sparks_dud; nat sparks_converted; - nat sparks_pruned; + nat sparks_gcd; + nat sparks_fizzled; #endif // Per-capability STM-related data @@ -234,11 +240,6 @@ void prodCapability (Capability *cap, Task *task); // 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, rtsBool wait_foreign); - // Attempt to gain control of a Capability if it is free. // rtsBool tryGrabCapability (Capability *cap, Task *task); @@ -264,6 +265,15 @@ extern void grabCapability (Capability **pCap); #endif /* !THREADED_RTS */ +// 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, rtsBool wait_foreign); + +// Shut down all capabilities. +// +void shutdownCapabilities(Task *task, rtsBool wait_foreign); + // cause all capabilities to context switch as soon as possible. void setContextSwitches(void); INLINE_HEADER void contextSwitchCapability(Capability *cap); @@ -272,9 +282,11 @@ INLINE_HEADER void contextSwitchCapability(Capability *cap); void freeCapabilities (void); // For the GC: -void markSomeCapabilities (evac_fn evac, void *user, nat i0, nat delta, - rtsBool prune_sparks); +void markCapability (evac_fn evac, void *user, Capability *cap, + rtsBool no_mark_sparks USED_IF_THREADS); + void markCapabilities (evac_fn evac, void *user); + void traverseSparkQueues (evac_fn evac, void *user); /* ----------------------------------------------------------------------------- @@ -354,6 +366,6 @@ INLINE_HEADER rtsBool emptyInbox(Capability *cap) #endif -END_RTS_PRIVATE +#include "EndPrivate.h" #endif /* CAPABILITY_H */