summaryrefslogtreecommitdiff
path: root/src/systemc/core/scheduler.cc
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-08-31 16:18:10 -0700
committerGabe Black <gabeblack@google.com>2018-10-03 00:28:55 +0000
commite99a575c78735ad9e35e30ee8714d5e2798e3014 (patch)
tree984e45897e33ab064d730550d7163be06403fcf0 /src/systemc/core/scheduler.cc
parent3c40f3c0c420dc4215c97a646359f7cda5de829e (diff)
downloadgem5-e99a575c78735ad9e35e30ee8714d5e2798e3014.tar.xz
systemc: Store timed notifications in a list instead of a set.
This has three advantages. First, the data structure doesn't have to try to keep track of whether or not an event is already listed there. Second, it's easier to delete an item by storing an iterator for it when it gets inserted. Third, the ordering of events is not dependent on the arbitrary ordering of the set, it's bsaed on the fixed order the events get added to the list. One part of this change makes ScEvent-s keep track of what list they're on, and handle their own insertion and deletion when they're scheduled or descheduled. A side effect of that is that it's no longer safe to simply use a range based for loop to loop over all of an ScEvent and deschedule all its events or to run then (which deschedules them internally once they execute). That can be avoided by looping until the list is empty, and operating on the first element. As the first element is processed and removed from the list, the next element will become first and will get picked up in the next iteration. Change-Id: Icad51a63f153297c88e65f85d22ac721e6c571d8 Reviewed-on: https://gem5-review.googlesource.com/c/12456 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.cc19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc
index e2d8e62f4..d5081c667 100644
--- a/src/systemc/core/scheduler.cc
+++ b/src/systemc/core/scheduler.cc
@@ -61,15 +61,14 @@ void
Scheduler::clear()
{
// Delta notifications.
- for (auto &e: deltas)
- e->deschedule();
- deltas.clear();
+ while (!deltas.empty())
+ deltas.front()->deschedule();
// Timed notifications.
for (auto &tsp: timeSlots) {
TimeSlot *&ts = tsp.second;
- for (auto &e: ts->events)
- e->deschedule();
+ while (!ts->events.empty())
+ ts->events.front()->deschedule();
deschedule(ts);
}
timeSlots.clear();
@@ -115,9 +114,8 @@ Scheduler::initPhase()
update();
- for (auto &e: deltas)
- e->run();
- deltas.clear();
+ while (!deltas.empty())
+ deltas.front()->run();
for (auto ets: eventsToSchedule)
eq->schedule(ets.first, ets.second);
@@ -281,9 +279,8 @@ Scheduler::runReady()
update();
// The delta phase.
- for (auto &e: deltas)
- e->run();
- deltas.clear();
+ while (!deltas.empty())
+ deltas.front()->run();
if (!runToTime && starved())
scheduleStarvationEvent();