Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/12217
Change subject: systemc: Rework the init phase for the new way delta notes
are handled.
......................................................................
systemc: Rework the init phase for the new way delta notes are handled.
The initialization phase had been done in a somewhat adhoc way,
partially because delta notifications were being handled as top level
gem5 events which were ordered based on their priorities. This change
makes the initialization phase happen more explicitly, and more in the
order in the spec.
Change-Id: I91d56b63fefcb81c845c52c97826a976a7559fad
---
M src/systemc/core/kernel.cc
M src/systemc/core/scheduler.cc
M src/systemc/core/scheduler.hh
3 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/src/systemc/core/kernel.cc b/src/systemc/core/kernel.cc
index 84bdfd1..2594bcc 100644
--- a/src/systemc/core/kernel.cc
+++ b/src/systemc/core/kernel.cc
@@ -163,14 +163,7 @@
void
Kernel::t0Handler()
{
- // Now that the event queue has started, mark all the processes that
- // need to be initialized as ready to run.
- //
- // This event has greater priority than delta notifications and so will
- // happen before them, honoring the ordering for the initialization
phase
- // in the spec. The delta phase will happen at normal priority, and
then
- // the event which runs the processes which is at a lower priority.
- ::sc_gem5::scheduler.prepareForInit();
+ ::sc_gem5::scheduler.initPhase();
status(::sc_core::SC_RUNNING);
}
diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc
index ceaa5f4..77015dd 100644
--- a/src/systemc/core/scheduler.cc
+++ b/src/systemc/core/scheduler.cc
@@ -46,12 +46,12 @@
starvationEvent(this, false, StarvationPriority),
_started(false), _paused(false), _stopped(false),
maxTickEvent(this, false, MaxTickPriority),
- _numCycles(0), _current(nullptr), initReady(false),
+ _numCycles(0), _current(nullptr), initDone(false),
runOnce(false)
{}
void
-Scheduler::prepareForInit()
+Scheduler::initPhase()
{
for (Process *p = toFinalize.getNext(); p; p = toFinalize.getNext()) {
p->finalize();
@@ -64,6 +64,12 @@
p->ready();
}
+ update();
+
+ for (auto &e: deltas)
+ e->run();
+ deltas.clear();
+
for (auto ets: eventsToSchedule)
eq->schedule(ets.first, ets.second);
eventsToSchedule.clear();
@@ -71,13 +77,13 @@
if (_started)
eq->schedule(&maxTickEvent, maxTick);
- initReady = true;
+ initDone = true;
}
void
Scheduler::reg(Process *p)
{
- if (initReady) {
+ if (initDone) {
// If we're past initialization, finalize static sensitivity.
p->finalize();
// Mark the process as ready.
@@ -92,7 +98,7 @@
void
Scheduler::dontInitialize(Process *p)
{
- if (initReady) {
+ if (initDone) {
// Pop this process off of the ready list.
p->popListNode();
} else {
@@ -246,7 +252,7 @@
if (starved() && !runToTime)
return;
- if (initReady) {
+ if (initDone) {
kernel->status(::sc_core::SC_RUNNING);
eq->schedule(&maxTickEvent, maxTick);
}
diff --git a/src/systemc/core/scheduler.hh b/src/systemc/core/scheduler.hh
index b221e67..2843b68 100644
--- a/src/systemc/core/scheduler.hh
+++ b/src/systemc/core/scheduler.hh
@@ -165,8 +165,7 @@
uint64_t numCycles() { return _numCycles; }
Process *current() { return _current; }
- // Prepare for initialization.
- void prepareForInit();
+ void initPhase();
// Register a process with the scheduler.
void reg(Process *p);
@@ -226,7 +225,7 @@
TimeSlot *&ts = timeSlots[tick];
if (!ts) {
ts = new TimeSlot;
- if (initReady)
+ if (initDone)
eq->schedule(ts, tick);
else
eventsToSchedule[ts] = tick;
@@ -256,7 +255,7 @@
// If no more events are happening at this time slot, get rid of
it.
if (events.empty()) {
- if (initReady)
+ if (initDone)
eq->deschedule(ts);
else
eventsToSchedule.erase(ts);
@@ -363,7 +362,7 @@
Process *_current;
- bool initReady;
+ bool initDone;
bool runToTime;
bool runOnce;
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12217
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I91d56b63fefcb81c845c52c97826a976a7559fad
Gerrit-Change-Number: 12217
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev