summaryrefslogtreecommitdiff
path: root/rts/Timer.c
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-09-27 01:50:37 +0000
committerBen Gamari <ben@smart-cactus.org>2020-10-24 21:00:37 -0400
commitf88710185acc0e02b334b96004f4b8fae38c5eb9 (patch)
tree72e5e494575f6c9b23ba64553ec3bed7f4cc94ad /rts/Timer.c
parent8d2b3c3d1fcb9009b6dfcce85777e04bcec9d219 (diff)
downloadhaskell-f88710185acc0e02b334b96004f4b8fae38c5eb9.tar.gz
rts/Schedule: Eliminate data races on recent_activity
We cannot safely use relaxed atomics here.
Diffstat (limited to 'rts/Timer.c')
-rw-r--r--rts/Timer.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/rts/Timer.c b/rts/Timer.c
index 057cffc7c9..990eba6b05 100644
--- a/rts/Timer.c
+++ b/rts/Timer.c
@@ -106,16 +106,16 @@ handle_tick(int unused STG_UNUSED)
* for threads that are deadlocked. However, ensure we wait
* at least interIdleGCWait (+RTS -Iw) between idle GCs.
*/
- switch (recent_activity) {
+ switch (SEQ_CST_LOAD(&recent_activity)) {
case ACTIVITY_YES:
- recent_activity = ACTIVITY_MAYBE_NO;
+ SEQ_CST_STORE(&recent_activity, ACTIVITY_MAYBE_NO);
idle_ticks_to_gc = RtsFlags.GcFlags.idleGCDelayTime /
RtsFlags.MiscFlags.tickInterval;
break;
case ACTIVITY_MAYBE_NO:
if (idle_ticks_to_gc == 0 && inter_gc_ticks_to_gc == 0) {
if (RtsFlags.GcFlags.doIdleGC) {
- recent_activity = ACTIVITY_INACTIVE;
+ SEQ_CST_STORE(&recent_activity, ACTIVITY_INACTIVE);
inter_gc_ticks_to_gc = RtsFlags.GcFlags.interIdleGCWait /
RtsFlags.MiscFlags.tickInterval;
#if defined(THREADED_RTS)
@@ -124,7 +124,7 @@ handle_tick(int unused STG_UNUSED)
// the GC.
#endif
} else {
- recent_activity = ACTIVITY_DONE_GC;
+ SEQ_CST_STORE(&recent_activity, ACTIVITY_DONE_GC);
// disable timer signals (see #1623, #5991, #9105)
// but only if we're not profiling (e.g. passed -h or -p RTS
// flags). If we are profiling we need to keep the timer active