diff options
author | Gabe Black <gabeblack@google.com> | 2018-08-21 15:29:15 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2018-09-25 23:53:16 +0000 |
commit | 508929475d776645bcdb15956d7a98888dc54669 (patch) | |
tree | 47f1c7e27786dddedc06846a1ece66599262a866 /src/systemc/core/scheduler.cc | |
parent | 12d4a14b9a673d5b55bd099fb782e6dcbcc02287 (diff) | |
download | gem5-508929475d776645bcdb15956d7a98888dc54669.tar.xz |
systemc: Improve scheduler cleanup.
Make the scheduler clear itself out when it's destructed to ensure that
nobody will try to use it after it's gone away. Also make sure there
are no pending events which might refer to it as well, either systemc
events or gem5 events.
Change-Id: I12dadc06bd9db7016a8dc0c1827b3e630b0d23d5
Reviewed-on: https://gem5-review.googlesource.com/12222
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/core/scheduler.cc')
-rw-r--r-- | src/systemc/core/scheduler.cc | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc index cdebd9986..6762086a0 100644 --- a/src/systemc/core/scheduler.cc +++ b/src/systemc/core/scheduler.cc @@ -50,6 +50,48 @@ Scheduler::Scheduler() : runOnce(false) {} +Scheduler::~Scheduler() +{ + // Clear out everything that belongs to us to make sure nobody tries to + // clear themselves out after the scheduler goes away. + + // Delta notifications. + for (auto &e: deltas) + e->deschedule(); + + // Timed notifications. + for (auto &ts: timeSlots) { + for (auto &e: ts.second->events) + e->deschedule(); + delete ts.second; + ts.second = nullptr; + } + + // gem5 events. + if (readyEvent.scheduled()) + eq->deschedule(&readyEvent); + if (pauseEvent.scheduled()) + eq->deschedule(&pauseEvent); + if (stopEvent.scheduled()) + eq->deschedule(&stopEvent); + if (starvationEvent.scheduled()) + eq->deschedule(&starvationEvent); + if (maxTickEvent.scheduled()) + eq->deschedule(&maxTickEvent); + + Process *p; + while ((p = toFinalize.getNext())) + p->popListNode(); + while ((p = initList.getNext())) + p->popListNode(); + while ((p = readyList.getNext())) + p->popListNode(); + + Channel *c; + while ((c = updateList.getNext())) + c->popListNode(); +} + void Scheduler::initPhase() { |