summaryrefslogtreecommitdiff
path: root/rts/Schedule.h
diff options
context:
space:
mode:
authorBen Gamari <ben@well-typed.com>2018-07-19 21:57:14 -0400
committerBen Gamari <ben@smart-cactus.org>2019-10-18 15:27:42 -0400
commitbfcafd39abc9d5f466f2fd284ebb5dbd45b42694 (patch)
tree34102b69c42c3c46469d50867d846c26160023d3 /rts/Schedule.h
parentc4c9904b324736dc5d190a91418e8d8f564d4104 (diff)
downloadhaskell-bfcafd39abc9d5f466f2fd284ebb5dbd45b42694.tar.gz
rts/Schedule: Allow synchronization without holding a capabilitywip/gc/sync-without-capability
The concurrent mark-and-sweep will be performed by a GHC task which will not hold a capability. This is necessary to avoid a concurrent mark from interfering with minor generation collections. However, the major collector must synchronize with the mutators at the end of marking to flush their update remembered sets. This patch extends the `requestSync` mechanism used to synchronize garbage collectors to allow synchronization without holding a capability. This change is fairly straightforward as the capability was previously only required for two reasons: 1. to ensure that we don't try to re-acquire a capability that we the sync requestor already holds. 2. to provide a way to suspend and later resume the sync request if there is already a sync pending. When synchronizing without holding a capability we needn't worry about consideration (1) at all. (2) is slightly trickier and may happen, for instance, when a capability requests a minor collection and shortly thereafter the non-moving mark thread requests a post-mark synchronization. In this case we need to ensure that the non-moving mark thread suspends his request until after the minor GC has concluded to avoid dead-locking. For this we introduce a condition variable, `sync_finished_cond`, which a non-capability-bearing requestor will wait on and which is signalled after a synchronization or GC has finished.
Diffstat (limited to 'rts/Schedule.h')
-rw-r--r--rts/Schedule.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/rts/Schedule.h b/rts/Schedule.h
index 66cf8391f3..a4772295d9 100644
--- a/rts/Schedule.h
+++ b/rts/Schedule.h
@@ -49,6 +49,12 @@ StgWord findRetryFrameHelper (Capability *cap, StgTSO *tso);
/* Entry point for a new worker */
void scheduleWorker (Capability *cap, Task *task);
+#if defined(THREADED_RTS)
+void stopAllCapabilitiesWith (Capability **pCap, Task *task, SyncType sync_type);
+void stopAllCapabilities (Capability **pCap, Task *task);
+void releaseAllCapabilities(uint32_t n, Capability *keep_cap, Task *task);
+#endif
+
/* The state of the scheduler. This is used to control the sequence
* of events during shutdown. See Note [shutdown] in Schedule.c.
*/