From 382066d462d11728a0c9598d1698765da7a05293 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Wed, 22 Aug 2018 14:54:08 -0700 Subject: 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 Maintainer: Gabe Black --- src/systemc/core/scheduler.cc | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'src/systemc/core/scheduler.cc') 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()); } -- cgit v1.2.3