summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-08-22 14:54:08 -0700
committerGabe Black <gabeblack@google.com>2018-09-25 23:55:43 +0000
commit382066d462d11728a0c9598d1698765da7a05293 (patch)
treea7eb95ef6e9b44a500e30ecdf9cd4f50ededef71 /src
parent71eeee982485916df7a849d1ebd67525fac3cd86 (diff)
downloadgem5-382066d462d11728a0c9598d1698765da7a05293.tar.xz
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 Reviewed-on: https://gem5-review.googlesource.com/12248 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/systemc/core/scheduler.cc32
-rw-r--r--src/systemc/core/scheduler.hh2
2 files changed, 17 insertions, 17 deletions
diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc
index f930bb515..58c79562f 100644
--- a/src/systemc/core/scheduler.cc
+++ b/src/systemc/core/scheduler.cc
@@ -54,18 +54,25 @@ Scheduler::~Scheduler()
{
// 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 @@ Scheduler::stop()
_stopped = true;
kernel->stop();
- if (readyEvent.scheduled())
- eq->deschedule(&readyEvent);
+ clear();
runOnce = false;
scMain->run();
@@ -338,17 +344,9 @@ Scheduler::scheduleStop(bool finish_delta)
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 24b7fd2ff..697aa11ad 100644
--- a/src/systemc/core/scheduler.hh
+++ b/src/systemc/core/scheduler.hh
@@ -161,6 +161,8 @@ class Scheduler
Scheduler();
~Scheduler();
+ void clear();
+
const std::string name() const { return "systemc_scheduler"; }
uint64_t numCycles() { return _numCycles; }