From e752df70150b1af370944eedfc514fea816c0b1e Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Fri, 17 Aug 2018 17:48:56 -0700 Subject: systemc: Generalize gem5 style event scheduling. These events are either scheduled directly, or if no event queue is yet available they're recorded in a map to schedule later. Since this was used in a few places (and should have been used for the ready event), this change moves it into some common functions which remove some duplication and abstract away this detail. Change-Id: I4320d7296f4f72344539b2b4b2564a6a27576dd8 Reviewed-on: https://gem5-review.googlesource.com/12219 Reviewed-by: Gabe Black Maintainer: Gabe Black --- src/systemc/core/scheduler.hh | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'src/systemc/core/scheduler.hh') diff --git a/src/systemc/core/scheduler.hh b/src/systemc/core/scheduler.hh index 2843b6829..c22bdf870 100644 --- a/src/systemc/core/scheduler.hh +++ b/src/systemc/core/scheduler.hh @@ -225,10 +225,7 @@ class Scheduler TimeSlot *&ts = timeSlots[tick]; if (!ts) { ts = new TimeSlot; - if (initDone) - eq->schedule(ts, tick); - else - eventsToSchedule[ts] = tick; + schedule(ts, tick); } ts->events.insert(event); } @@ -255,10 +252,7 @@ class Scheduler // If no more events are happening at this time slot, get rid of it. if (events.empty()) { - if (initDone) - eq->deschedule(ts); - else - eventsToSchedule.erase(ts); + deschedule(ts); timeSlots.erase(tsit); } } @@ -328,6 +322,27 @@ class Scheduler EventQueue *eq; + // For gem5 style events. + void + schedule(::Event *event, Tick tick) + { + if (initDone) + eq->schedule(event, tick); + else + eventsToSchedule[event] = tick; + } + + void schedule(::Event *event) { schedule(event, getCurTick()); } + + void + deschedule(::Event *event) + { + if (initDone) + eq->deschedule(event); + else + eventsToSchedule.erase(event); + } + ScEvents deltas; TimeSlots timeSlots; -- cgit v1.2.3