From 026b3f909e6eb180f1fffb1a1c05317224f1ca29 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Sat, 1 Sep 2018 18:27:02 -0700 Subject: [PATCH] systemc: When stopping immediately, block new processes/updates. When stopping immediately, we're supposed to finish the current process but not run any other processes or go to the update phase. The rest of the process could introduce new processes or request new updates, so we need to make sure we block those if we're in the process of stopping. Change-Id: I9cc867d294cf171dfedb4b9d43fbc167c2057de8 Reviewed-on: https://gem5-review.googlesource.com/c/12466 Reviewed-by: Gabe Black Maintainer: Gabe Black --- src/systemc/core/scheduler.cc | 9 ++++++++- src/systemc/core/scheduler.hh | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc index eda4ed7e4..cf34fe8b7 100644 --- a/src/systemc/core/scheduler.cc +++ b/src/systemc/core/scheduler.cc @@ -44,7 +44,7 @@ Scheduler::Scheduler() : stopEvent(this, false, StopPriority), scMain(nullptr), starvationEvent(this, false, StarvationPriority), - _started(false), _paused(false), _stopped(false), + _started(false), _paused(false), _stopped(false), _stopNow(false), maxTickEvent(this, false, MaxTickPriority), _numCycles(0), _changeStamp(0), _current(nullptr), initDone(false), runOnce(false) @@ -189,6 +189,9 @@ Scheduler::yield() void Scheduler::ready(Process *p) { + if (_stopNow) + return; + // Clump methods together to minimize context switching. static bool cluster_methods = false; @@ -277,6 +280,9 @@ Scheduler::runReady() _changeStamp++; } + if (_stopNow) + return; + // The update phase. update(); @@ -383,6 +389,7 @@ Scheduler::scheduleStop(bool finish_delta) return; if (!finish_delta) { + _stopNow = true; // If we're not supposed to finish the delta cycle, flush all // pending activity. clear(); diff --git a/src/systemc/core/scheduler.hh b/src/systemc/core/scheduler.hh index 924cfb29e..f0cbac43c 100644 --- a/src/systemc/core/scheduler.hh +++ b/src/systemc/core/scheduler.hh @@ -386,6 +386,7 @@ class Scheduler bool _started; bool _paused; bool _stopped; + bool _stopNow; Tick maxTick; Tick lastReadyTick; -- 2.30.2