systemc: When stopping immediately, block new processes/updates.
authorGabe Black <gabeblack@google.com>
Sun, 2 Sep 2018 01:27:02 +0000 (18:27 -0700)
committerGabe Black <gabeblack@google.com>
Wed, 3 Oct 2018 00:50:23 +0000 (00:50 +0000)
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 <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>

src/systemc/core/scheduler.cc
src/systemc/core/scheduler.hh

index eda4ed7e4510d076c7801d889b2619a44916f951..cf34fe8b7c38789fcf87c0a786f72050814a7f06 100644 (file)
@@ -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();
index 924cfb29e8ae54ac951358b62c724998571ba685..f0cbac43cd6d81e79edd74741df8727cf34a6d7b 100644 (file)
@@ -386,6 +386,7 @@ class Scheduler
     bool _started;
     bool _paused;
     bool _stopped;
+    bool _stopNow;
 
     Tick maxTick;
     Tick lastReadyTick;