1/* 2 * Copyright 2018 Google, Inc. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer; 8 * redistributions in binary form must reproduce the above copyright --- 32 unchanged lines hidden (view full) --- 41Scheduler::Scheduler() : 42 eq(nullptr), readyEvent(this, false, ReadyPriority), 43 pauseEvent(this, false, PausePriority), 44 stopEvent(this, false, StopPriority), 45 scMain(nullptr), 46 starvationEvent(this, false, StarvationPriority), 47 _started(false), _paused(false), _stopped(false), 48 maxTickEvent(this, false, MaxTickPriority), |
49 _numCycles(0), _current(nullptr), initDone(false), |
50 runOnce(false) 51{} 52 53void |
54Scheduler::initPhase() |
55{ 56 for (Process *p = toFinalize.getNext(); p; p = toFinalize.getNext()) { 57 p->finalize(); 58 p->popListNode(); 59 } 60 61 for (Process *p = initList.getNext(); p; p = initList.getNext()) { 62 p->finalize(); 63 p->popListNode(); 64 p->ready(); 65 } 66 |
67 update(); 68 69 for (auto &e: deltas) 70 e->run(); 71 deltas.clear(); 72 |
73 for (auto ets: eventsToSchedule) 74 eq->schedule(ets.first, ets.second); 75 eventsToSchedule.clear(); 76 77 if (_started) 78 eq->schedule(&maxTickEvent, maxTick); 79 |
80 initDone = true; |
81} 82 83void 84Scheduler::reg(Process *p) 85{ |
86 if (initDone) { |
87 // If we're past initialization, finalize static sensitivity. 88 p->finalize(); 89 // Mark the process as ready. 90 p->ready(); 91 } else { 92 // Otherwise, record that this process should be initialized once we 93 // get there. 94 initList.pushLast(p); 95 } 96} 97 98void 99Scheduler::dontInitialize(Process *p) 100{ |
101 if (initDone) { |
102 // Pop this process off of the ready list. 103 p->popListNode(); 104 } else { 105 // Push this process onto the list of processes which still need 106 // their static sensitivity to be finalized. That implicitly pops it 107 // off the list of processes to be initialized/marked ready. 108 toFinalize.pushLast(p); 109 } --- 137 unchanged lines hidden (view full) --- 247 _stopped = false; 248 runToTime = run_to_time; 249 250 maxTick = max_tick; 251 252 if (starved() && !runToTime) 253 return; 254 |
255 if (initDone) { |
256 kernel->status(::sc_core::SC_RUNNING); 257 eq->schedule(&maxTickEvent, maxTick); 258 } 259 260 // Return to gem5 to let it run events, etc. 261 Fiber::primaryFiber()->run(); 262 263 if (pauseEvent.scheduled()) --- 50 unchanged lines hidden --- |