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);
}
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();
p->ready();
}
+ update();
+
+ for (auto &e: deltas)
+ e->run();
+ deltas.clear();
+
for (auto ets: eventsToSchedule)
eq->schedule(ets.first, ets.second);
eventsToSchedule.clear();
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.
void
Scheduler::dontInitialize(Process *p)
{
- if (initReady) {
+ if (initDone) {
// Pop this process off of the ready list.
p->popListNode();
} else {
if (starved() && !runToTime)
return;
- if (initReady) {
+ if (initDone) {
kernel->status(::sc_core::SC_RUNNING);
eq->schedule(&maxTickEvent, maxTick);
}
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);
TimeSlot *&ts = timeSlots[tick];
if (!ts) {
ts = new TimeSlot;
- if (initReady)
+ if (initDone)
eq->schedule(ts, tick);
else
eventsToSchedule[ts] = tick;
// 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);
Process *_current;
- bool initReady;
+ bool initDone;
bool runToTime;
bool runOnce;