_elaborationDone(false), _started(false), _stopNow(false),
_status(StatusOther), maxTickEvent(this, false, MaxTickPriority),
_numCycles(0), _changeStamp(0), _current(nullptr), initDone(false),
- runOnce(false), readyList(nullptr)
+ runOnce(false)
{}
Scheduler::~Scheduler()
Scheduler::yield()
{
// Pull a process from the active list.
- _current = readyList->getNext();
+ _current = getNextReady();
if (!_current) {
// There are no more processes, so return control to evaluate.
Fiber::primaryFiber()->run();
// The evaluation phase.
do {
- // We run methods and threads in two seperate passes to emulate how
- // Accellera orders things, but without having to scan through a
- // unified list to find the next process of the correct type.
- readyList = &readyListMethods;
- while (!readyListMethods.empty())
- yield();
-
- readyList = &readyListThreads;
- while (!readyListThreads.empty())
- yield();
-
- // We already know that readyListThreads is empty at this point.
- } while (!readyListMethods.empty());
+ yield();
+ } while (getNextReady());
if (!empty) {
_numCycles++;
void
runNow(Process *p)
{
- // This function may put a process on the wrong list, ie a method on
- // the process list or vice versa. That's fine since that's just a
- // performance optimization, and the important thing here is how the
- // processes are ordered.
+ // This function may put a process on the wrong list, ie a thread
+ // the method list. That's fine since that's just a performance
+ // optimization, and the important thing here is how the processes are
+ // ordered.
// If a process is running, schedule it/us to run again.
if (_current)
- readyList->pushFirst(_current);
+ readyListMethods.pushFirst(_current);
// Schedule p to run first.
- readyList->pushFirst(p);
+ readyListMethods.pushFirst(p);
yield();
}
ScEvents deltas;
TimeSlots timeSlots;
+ Process *
+ getNextReady()
+ {
+ Process *p = readyListMethods.getNext();
+ return p ? p : readyListThreads.getNext();
+ }
+
void runReady();
EventWrapper<Scheduler, &Scheduler::runReady> readyEvent;
void scheduleReadyEvent();
ProcessList initList;
- ProcessList *readyList;
ProcessList readyListMethods;
ProcessList readyListThreads;