scheduler.cc (13207:034ca389a810) | scheduler.cc (13209:aad30faa966b) |
---|---|
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 --- 35 unchanged lines hidden (view full) --- 44 eq(nullptr), readyEvent(this, false, ReadyPriority), 45 pauseEvent(this, false, PausePriority), 46 stopEvent(this, false, StopPriority), 47 scMain(nullptr), _throwToScMain(nullptr), 48 starvationEvent(this, false, StarvationPriority), 49 _elaborationDone(false), _started(false), _stopNow(false), 50 _status(StatusOther), maxTickEvent(this, false, MaxTickPriority), 51 _numCycles(0), _changeStamp(0), _current(nullptr), initDone(false), | 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 --- 35 unchanged lines hidden (view full) --- 44 eq(nullptr), readyEvent(this, false, ReadyPriority), 45 pauseEvent(this, false, PausePriority), 46 stopEvent(this, false, StopPriority), 47 scMain(nullptr), _throwToScMain(nullptr), 48 starvationEvent(this, false, StarvationPriority), 49 _elaborationDone(false), _started(false), _stopNow(false), 50 _status(StatusOther), maxTickEvent(this, false, MaxTickPriority), 51 _numCycles(0), _changeStamp(0), _current(nullptr), initDone(false), |
52 runOnce(false), readyList(nullptr) | 52 runOnce(false) |
53{} 54 55Scheduler::~Scheduler() 56{ 57 // Clear out everything that belongs to us to make sure nobody tries to 58 // clear themselves out after the scheduler goes away. 59 clear(); 60} --- 88 unchanged lines hidden (view full) --- 149 initList.pushLast(p); 150 } 151} 152 153void 154Scheduler::yield() 155{ 156 // Pull a process from the active list. | 53{} 54 55Scheduler::~Scheduler() 56{ 57 // Clear out everything that belongs to us to make sure nobody tries to 58 // clear themselves out after the scheduler goes away. 59 clear(); 60} --- 88 unchanged lines hidden (view full) --- 149 initList.pushLast(p); 150 } 151} 152 153void 154Scheduler::yield() 155{ 156 // Pull a process from the active list. |
157 _current = readyList->getNext(); | 157 _current = getNextReady(); |
158 if (!_current) { 159 // There are no more processes, so return control to evaluate. 160 Fiber::primaryFiber()->run(); 161 } else { 162 _current->popListNode(); 163 // Switch to whatever Fiber is supposed to run this process. All 164 // Fibers which aren't running should be parked at this line. 165 _current->fiber()->run(); --- 95 unchanged lines hidden (view full) --- 261void 262Scheduler::runReady() 263{ 264 bool empty = readyListMethods.empty() && readyListThreads.empty(); 265 lastReadyTick = getCurTick(); 266 267 // The evaluation phase. 268 do { | 158 if (!_current) { 159 // There are no more processes, so return control to evaluate. 160 Fiber::primaryFiber()->run(); 161 } else { 162 _current->popListNode(); 163 // Switch to whatever Fiber is supposed to run this process. All 164 // Fibers which aren't running should be parked at this line. 165 _current->fiber()->run(); --- 95 unchanged lines hidden (view full) --- 261void 262Scheduler::runReady() 263{ 264 bool empty = readyListMethods.empty() && readyListThreads.empty(); 265 lastReadyTick = getCurTick(); 266 267 // The evaluation phase. 268 do { |
269 // We run methods and threads in two seperate passes to emulate how 270 // Accellera orders things, but without having to scan through a 271 // unified list to find the next process of the correct type. 272 readyList = &readyListMethods; 273 while (!readyListMethods.empty()) 274 yield(); | 269 yield(); 270 } while (getNextReady()); |
275 | 271 |
276 readyList = &readyListThreads; 277 while (!readyListThreads.empty()) 278 yield(); 279 280 // We already know that readyListThreads is empty at this point. 281 } while (!readyListMethods.empty()); 282 | |
283 if (!empty) { 284 _numCycles++; 285 _changeStamp++; 286 } 287 288 if (_stopNow) 289 return; 290 --- 193 unchanged lines hidden --- | 272 if (!empty) { 273 _numCycles++; 274 _changeStamp++; 275 } 276 277 if (_stopNow) 278 return; 279 --- 193 unchanged lines hidden --- |