systemc: Don't schedule the ready event unnecessarily.
authorGabe Black <gabeblack@google.com>
Sat, 22 Sep 2018 11:51:29 +0000 (04:51 -0700)
committerGabe Black <gabeblack@google.com>
Tue, 16 Oct 2018 00:25:40 +0000 (00:25 +0000)
If we're already going to process the thing we'd be scheduling it to
process, just let the existing invocation get to it.

Change-Id: Ifeebc80903065567fc0eed02beefec6156b22ff7
Reviewed-on: https://gem5-review.googlesource.com/c/12964
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>

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

index 9deb077334b2e7baeb435776f8d58dc52afcaed0..ae1aa899fb1f56c4cea5fc3136f05f6cb3f1ab63 100644 (file)
@@ -193,7 +193,8 @@ Scheduler::ready(Process *p)
     else
         readyListThreads.pushLast(p);
 
-    scheduleReadyEvent();
+    if (!inEvaluate())
+        scheduleReadyEvent();
 }
 
 void
@@ -234,7 +235,8 @@ void
 Scheduler::requestUpdate(Channel *c)
 {
     updateList.pushLast(c);
-    scheduleReadyEvent();
+    if (!inEvaluate())
+        scheduleReadyEvent();
 }
 
 void
@@ -274,8 +276,10 @@ Scheduler::runReady()
         _changeStamp++;
     }
 
-    if (_stopNow)
+    if (_stopNow) {
+        status(StatusOther);
         return;
+    }
 
     runUpdate();
     runDelta();
index ad1467ea13941f42282191f4b7e42c3ab841c0ed..8015260a3e35979709662559d0e71f158b4c2b03 100644 (file)
@@ -231,7 +231,8 @@ class Scheduler
         // Delta notification/timeout.
         if (delay.value() == 0) {
             event->schedule(deltas, tick);
-            scheduleReadyEvent();
+            if (!inEvaluate() && !inUpdate())
+                scheduleReadyEvent();
             return;
         }
 
@@ -331,8 +332,9 @@ class Scheduler
     enum Status
     {
         StatusOther = 0,
-        StatusDelta,
+        StatusEvaluate,
         StatusUpdate,
+        StatusDelta,
         StatusTiming,
         StatusPaused,
         StatusStopped
@@ -343,8 +345,9 @@ class Scheduler
 
     bool paused() { return status() == StatusPaused; }
     bool stopped() { return status() == StatusStopped; }
-    bool inDelta() { return status() == StatusDelta; }
+    bool inEvaluate() { return status() == StatusEvaluate; }
     bool inUpdate() { return status() == StatusUpdate; }
+    bool inDelta() { return status() == StatusDelta; }
     bool inTiming() { return status() == StatusTiming; }
 
     uint64_t changeStamp() { return _changeStamp; }