scheduler.cc (12985:ec84697e4e63) | scheduler.cc (12987:97fbdee919d8) |
---|---|
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 --- 28 unchanged lines hidden (view full) --- 37 38namespace sc_gem5 39{ 40 41Scheduler::Scheduler() : 42 eq(nullptr), readyEvent(this, false, ReadyPriority), 43 pauseEvent(this, false, PausePriority), 44 stopEvent(this, false, StopPriority), | 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 --- 28 unchanged lines hidden (view full) --- 37 38namespace sc_gem5 39{ 40 41Scheduler::Scheduler() : 42 eq(nullptr), readyEvent(this, false, ReadyPriority), 43 pauseEvent(this, false, PausePriority), 44 stopEvent(this, false, StopPriority), |
45 scMain(nullptr), _started(false), _paused(false), _stopped(false), | 45 scMain(nullptr), 46 starvationEvent(this, false, StarvationPriority), 47 _started(false), _paused(false), _stopped(false), |
46 maxTickEvent(this, false, MaxTickPriority), 47 _numCycles(0), _current(nullptr), initReady(false) 48{} 49 50void 51Scheduler::prepareForInit() 52{ 53 for (Process *p = toFinalize.getNext(); p; p = toFinalize.getNext()) { --- 84 unchanged lines hidden (view full) --- 138 139void 140Scheduler::scheduleReadyEvent() 141{ 142 // Schedule the evaluate and update phases. 143 if (!readyEvent.scheduled()) { 144 panic_if(!eq, "Need to schedule ready, but no event manager.\n"); 145 eq->schedule(&readyEvent, eq->getCurTick()); | 48 maxTickEvent(this, false, MaxTickPriority), 49 _numCycles(0), _current(nullptr), initReady(false) 50{} 51 52void 53Scheduler::prepareForInit() 54{ 55 for (Process *p = toFinalize.getNext(); p; p = toFinalize.getNext()) { --- 84 unchanged lines hidden (view full) --- 140 141void 142Scheduler::scheduleReadyEvent() 143{ 144 // Schedule the evaluate and update phases. 145 if (!readyEvent.scheduled()) { 146 panic_if(!eq, "Need to schedule ready, but no event manager.\n"); 147 eq->schedule(&readyEvent, eq->getCurTick()); |
148 if (starvationEvent.scheduled()) 149 eq->deschedule(&starvationEvent); |
|
146 } 147} 148 149void | 150 } 151} 152 153void |
154Scheduler::scheduleStarvationEvent() 155{ 156 if (!starvationEvent.scheduled()) { 157 panic_if(!eq, "Need to schedule starvation event, " 158 "but no event manager.\n"); 159 eq->schedule(&starvationEvent, eq->getCurTick()); 160 if (readyEvent.scheduled()) 161 eq->deschedule(&readyEvent); 162 } 163} 164 165void |
|
150Scheduler::runReady() 151{ 152 bool empty = readyList.empty(); 153 154 // The evaluation phase. 155 do { 156 yield(); 157 } while (!readyList.empty()); 158 159 if (!empty) 160 _numCycles++; 161 162 // The update phase. 163 update(); 164 | 166Scheduler::runReady() 167{ 168 bool empty = readyList.empty(); 169 170 // The evaluation phase. 171 do { 172 yield(); 173 } while (!readyList.empty()); 174 175 if (!empty) 176 _numCycles++; 177 178 // The update phase. 179 update(); 180 |
181 if (starved() && !runToTime) 182 scheduleStarvationEvent(); 183 |
|
165 // The delta phase will happen naturally through the event queue. 166} 167 168void 169Scheduler::update() 170{ 171 Channel *channel = updateList.getNext(); 172 while (channel) { --- 24 unchanged lines hidden (view full) --- 197{ 198 // We should be running from sc_main. Keep track of that Fiber to return 199 // to later. 200 scMain = Fiber::currentFiber(); 201 202 _started = true; 203 _paused = false; 204 _stopped = false; | 184 // The delta phase will happen naturally through the event queue. 185} 186 187void 188Scheduler::update() 189{ 190 Channel *channel = updateList.getNext(); 191 while (channel) { --- 24 unchanged lines hidden (view full) --- 216{ 217 // We should be running from sc_main. Keep track of that Fiber to return 218 // to later. 219 scMain = Fiber::currentFiber(); 220 221 _started = true; 222 _paused = false; 223 _stopped = false; |
224 runToTime = run_to_time; |
|
205 206 maxTick = max_tick; 207 | 225 226 maxTick = max_tick; 227 |
228 if (starved() && !runToTime) 229 return; 230 |
|
208 if (initReady) { 209 kernel->status(::sc_core::SC_RUNNING); 210 eq->schedule(&maxTickEvent, maxTick); 211 } 212 213 // Return to gem5 to let it run events, etc. 214 Fiber::primaryFiber()->run(); 215 216 if (pauseEvent.scheduled()) 217 eq->deschedule(&pauseEvent); 218 if (stopEvent.scheduled()) 219 eq->deschedule(&stopEvent); 220 if (maxTickEvent.scheduled()) 221 eq->deschedule(&maxTickEvent); | 231 if (initReady) { 232 kernel->status(::sc_core::SC_RUNNING); 233 eq->schedule(&maxTickEvent, maxTick); 234 } 235 236 // Return to gem5 to let it run events, etc. 237 Fiber::primaryFiber()->run(); 238 239 if (pauseEvent.scheduled()) 240 eq->deschedule(&pauseEvent); 241 if (stopEvent.scheduled()) 242 eq->deschedule(&stopEvent); 243 if (maxTickEvent.scheduled()) 244 eq->deschedule(&maxTickEvent); |
245 if (starvationEvent.scheduled()) 246 eq->deschedule(&starvationEvent); |
|
222} 223 224void 225Scheduler::schedulePause() 226{ 227 if (pauseEvent.scheduled()) 228 return; 229 --- 25 unchanged lines hidden --- | 247} 248 249void 250Scheduler::schedulePause() 251{ 252 if (pauseEvent.scheduled()) 253 return; 254 --- 25 unchanged lines hidden --- |