32a33,34
> #include "base/logging.hh"
> #include "sim/eventq.hh"
37c39,42
< Scheduler::Scheduler() : _numCycles(0), _current(nullptr) {}
---
> Scheduler::Scheduler() :
> eq(nullptr), readyEvent(this, false, EventBase::Default_Pri + 1),
> _numCycles(0), _current(nullptr)
> {}
40c45
< Scheduler::initialize()
---
> Scheduler::initToReady()
42,43d46
< update();
<
46,47d48
<
< delta();
51,60d51
< Scheduler::runCycles()
< {
< while (!readyList.empty()) {
< evaluate();
< update();
< delta();
< }
< }
<
< void
80c71
< Scheduler::evaluate()
---
> Scheduler::ready(Process *p)
82,83c73,77
< if (!readyList.empty())
< _numCycles++;
---
> // Clump methods together to minimize context switching.
> if (p->procKind() == ::sc_core::SC_METHOD_PROC_)
> readyList.pushFirst(p);
> else
> readyList.pushLast(p);
85,87c79
< do {
< yield();
< } while (!readyList.empty());
---
> scheduleReadyEvent();
91c83
< Scheduler::update()
---
> Scheduler::requestUpdate(Channel *c)
92a85,86
> updateList.pushLast(c);
> scheduleReadyEvent();
96c90
< Scheduler::delta()
---
> Scheduler::scheduleReadyEvent()
97a92,96
> // Schedule the evaluate and update phases.
> if (!readyEvent.scheduled()) {
> panic_if(!eq, "Need to schedule ready, but no event manager.\n");
> eq->schedule(&readyEvent, eq->getCurTick());
> }
99a99,128
> void
> Scheduler::runReady()
> {
> bool empty = readyList.empty();
>
> // The evaluation phase.
> do {
> yield();
> } while (!readyList.empty());
>
> if (!empty)
> _numCycles++;
>
> // The update phase.
> update();
>
> // The delta phase will happen naturally through the event queue.
> }
>
> void
> Scheduler::update()
> {
> Channel *channel = updateList.getNext();
> while (channel) {
> channel->popListNode();
> channel->update();
> channel = updateList.getNext();
> }
> }
>