diff options
author | Gabe Black <gabeblack@google.com> | 2018-08-17 17:48:56 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2018-09-25 23:52:00 +0000 |
commit | e752df70150b1af370944eedfc514fea816c0b1e (patch) | |
tree | 4708ce70a91a15f0d4f0f9efd49ab3a1c713a408 /src/systemc/core/scheduler.hh | |
parent | a56dbe9338272273ac576514685e1c01ded173a2 (diff) | |
download | gem5-e752df70150b1af370944eedfc514fea816c0b1e.tar.xz |
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 <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/core/scheduler.hh')
-rw-r--r-- | src/systemc/core/scheduler.hh | 31 |
1 files changed, 23 insertions, 8 deletions
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; |