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>
This commit is contained in:
Gabe Black
2018-08-22 14:54:08 -07:00
parent 71eeee9824
commit 382066d462
2 changed files with 17 additions and 17 deletions

View File

@@ -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());
}

View File

@@ -161,6 +161,8 @@ class Scheduler
Scheduler();
~Scheduler();
void clear();
const std::string name() const { return "systemc_scheduler"; }
uint64_t numCycles() { return _numCycles; }