Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/12248

Change subject: systemc: Clear out the scheduler more agressively and with common code.
......................................................................

systemc: Clear out the scheduler more agressively and with common code.

It's be useful/necessary to flush pending activity even when not
tearing down the scheduler, specifically when stopping.

Change-Id: I6b3716a8ca1f8ca151222e08f30bd3c9a43364b9
---
M src/systemc/core/scheduler.cc
M src/systemc/core/scheduler.hh
2 files changed, 17 insertions(+), 17 deletions(-)



diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc
index f930bb5..58c7956 100644
--- a/src/systemc/core/scheduler.cc
+++ b/src/systemc/core/scheduler.cc
@@ -54,18 +54,25 @@
 {
     // Clear out everything that belongs to us to make sure nobody tries to
     // clear themselves out after the scheduler goes away.
+    clear();
+}

+void
+Scheduler::clear()
+{
     // Delta notifications.
     for (auto &e: deltas)
         e->deschedule();
+    deltas.clear();

     // Timed notifications.
-    for (auto &ts: timeSlots) {
-        for (auto &e: ts.second->events)
+    for (auto &tsp: timeSlots) {
+        TimeSlot *&ts = tsp.second;
+        for (auto &e: ts->events)
             e->deschedule();
-        delete ts.second;
-        ts.second = nullptr;
+        eq->deschedule(ts);
     }
+    timeSlots.clear();

     // gem5 events.
     if (readyEvent.scheduled())
@@ -273,8 +280,7 @@
     _stopped = true;
     kernel->stop();

-    if (readyEvent.scheduled())
-        eq->deschedule(&readyEvent);
+    clear();

     runOnce = false;
     scMain->run();
@@ -338,17 +344,9 @@
         return;

     if (!finish_delta) {
-        // If we're not supposed to finish the delta cycle, flush the list
-        // of ready processes, scheduled updates, and delta notifications.
-        Process *p;
-        while ((p = readyList.getNext()))
-            p->popListNode();
-        Channel *c;
-        while ((c = updateList.getNext()))
-            c->popListNode();
-        for (auto &e: deltas)
-            e->deschedule();
-        deltas.clear();
+        // If we're not supposed to finish the delta cycle, flush all
+        // pending activity.
+        clear();
     }
     eq->schedule(&stopEvent, eq->getCurTick());
 }
diff --git a/src/systemc/core/scheduler.hh b/src/systemc/core/scheduler.hh
index 24b7fd2..697aa11 100644
--- a/src/systemc/core/scheduler.hh
+++ b/src/systemc/core/scheduler.hh
@@ -161,6 +161,8 @@
     Scheduler();
     ~Scheduler();

+    void clear();
+
     const std::string name() const { return "systemc_scheduler"; }

     uint64_t numCycles() { return _numCycles; }

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12248
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I6b3716a8ca1f8ca151222e08f30bd3c9a43364b9
Gerrit-Change-Number: 12248
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to