scheduler.cc (13488:2e12afaa6cc7) | scheduler.cc (13701:d84e5d2979a7) |
---|---|
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 --- 33 unchanged lines hidden (view full) --- 42#include "systemc/utils/tracefile.hh" 43 44namespace sc_gem5 45{ 46 47Scheduler::Scheduler() : 48 eq(nullptr), readyEvent(this, false, ReadyPriority), 49 pauseEvent(this, false, PausePriority), | 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 --- 33 unchanged lines hidden (view full) --- 42#include "systemc/utils/tracefile.hh" 43 44namespace sc_gem5 45{ 46 47Scheduler::Scheduler() : 48 eq(nullptr), readyEvent(this, false, ReadyPriority), 49 pauseEvent(this, false, PausePriority), |
50 stopEvent(this, false, StopPriority), _throwToScMain(nullptr), | 50 stopEvent(this, false, StopPriority), _throwUp(nullptr), |
51 starvationEvent(this, false, StarvationPriority), 52 _elaborationDone(false), _started(false), _stopNow(false), 53 _status(StatusOther), maxTickEvent(this, false, MaxTickPriority), 54 timeAdvancesEvent(this, false, TimeAdvancesPriority), _numCycles(0), 55 _changeStamp(0), _current(nullptr), initDone(false), runOnce(false) 56{} 57 58Scheduler::~Scheduler() --- 116 unchanged lines hidden (view full) --- 175 _current->needsStart(false); 176 // If a process hasn't started yet, "resetting" it just starts it 177 // and signals its reset event. 178 if (_current->inReset()) 179 _current->resetEvent().notify(); 180 try { 181 _current->run(); 182 } catch (...) { | 51 starvationEvent(this, false, StarvationPriority), 52 _elaborationDone(false), _started(false), _stopNow(false), 53 _status(StatusOther), maxTickEvent(this, false, MaxTickPriority), 54 timeAdvancesEvent(this, false, TimeAdvancesPriority), _numCycles(0), 55 _changeStamp(0), _current(nullptr), initDone(false), runOnce(false) 56{} 57 58Scheduler::~Scheduler() --- 116 unchanged lines hidden (view full) --- 175 _current->needsStart(false); 176 // If a process hasn't started yet, "resetting" it just starts it 177 // and signals its reset event. 178 if (_current->inReset()) 179 _current->resetEvent().notify(); 180 try { 181 _current->run(); 182 } catch (...) { |
183 throwToScMain(); | 183 throwUp(); |
184 } 185 } 186 } 187 if (_current && !_current->needsStart()) { 188 if (_current->excWrapper) { 189 auto ew = _current->excWrapper; 190 _current->excWrapper = nullptr; 191 ew->throw_it(); --- 130 unchanged lines hidden (view full) --- 322 try { 323 Channel *channel = updateList.getNext(); 324 while (channel) { 325 channel->popListNode(); 326 channel->update(); 327 channel = updateList.getNext(); 328 } 329 } catch (...) { | 184 } 185 } 186 } 187 if (_current && !_current->needsStart()) { 188 if (_current->excWrapper) { 189 auto ew = _current->excWrapper; 190 _current->excWrapper = nullptr; 191 ew->throw_it(); --- 130 unchanged lines hidden (view full) --- 322 try { 323 Channel *channel = updateList.getNext(); 324 while (channel) { 325 channel->popListNode(); 326 channel->update(); 327 channel = updateList.getNext(); 328 } 329 } catch (...) { |
330 throwToScMain(); | 330 throwUp(); |
331 } 332} 333 334void 335Scheduler::runDelta() 336{ 337 status(StatusDelta); 338 339 try { 340 while (!deltas.empty()) 341 deltas.back()->run(); 342 } catch (...) { | 331 } 332} 333 334void 335Scheduler::runDelta() 336{ 337 status(StatusDelta); 338 339 try { 340 while (!deltas.empty()) 341 deltas.back()->run(); 342 } catch (...) { |
343 throwToScMain(); | 343 throwUp(); |
344 } 345} 346 347void 348Scheduler::pause() 349{ 350 status(StatusPaused); 351 kernel->status(::sc_core::SC_PAUSED); --- 41 unchanged lines hidden (view full) --- 393 deschedule(&pauseEvent); 394 if (stopEvent.scheduled()) 395 deschedule(&stopEvent); 396 if (maxTickEvent.scheduled()) 397 deschedule(&maxTickEvent); 398 if (starvationEvent.scheduled()) 399 deschedule(&starvationEvent); 400 | 344 } 345} 346 347void 348Scheduler::pause() 349{ 350 status(StatusPaused); 351 kernel->status(::sc_core::SC_PAUSED); --- 41 unchanged lines hidden (view full) --- 393 deschedule(&pauseEvent); 394 if (stopEvent.scheduled()) 395 deschedule(&stopEvent); 396 if (maxTickEvent.scheduled()) 397 deschedule(&maxTickEvent); 398 if (starvationEvent.scheduled()) 399 deschedule(&starvationEvent); 400 |
401 if (_throwToScMain) { 402 const ::sc_core::sc_report *to_throw = _throwToScMain; 403 _throwToScMain = nullptr; | 401 if (_throwUp) { 402 const ::sc_core::sc_report *to_throw = _throwUp; 403 _throwUp = nullptr; |
404 throw *to_throw; 405 } 406} 407 408void 409Scheduler::oneCycle() 410{ 411 runOnce = true; --- 6 unchanged lines hidden (view full) --- 418{ 419 if (pauseEvent.scheduled()) 420 return; 421 422 schedule(&pauseEvent); 423} 424 425void | 404 throw *to_throw; 405 } 406} 407 408void 409Scheduler::oneCycle() 410{ 411 runOnce = true; --- 6 unchanged lines hidden (view full) --- 418{ 419 if (pauseEvent.scheduled()) 420 return; 421 422 schedule(&pauseEvent); 423} 424 425void |
426Scheduler::throwToScMain() | 426Scheduler::throwUp() |
427{ | 427{ |
428 ::sc_core::sc_report report = reportifyException(); 429 _throwToScMain = &report; 430 status(StatusOther); 431 scMainFiber.run(); | 428 if (scMainFiber.called() && !scMainFiber.finished()) { 429 ::sc_core::sc_report report = reportifyException(); 430 _throwUp = &report; 431 status(StatusOther); 432 scMainFiber.run(); 433 } else { 434 reportHandlerProc(reportifyException(), 435 ::sc_core::sc_report_handler::get_catch_actions()); 436 } |
432} 433 434void 435Scheduler::scheduleStop(bool finish_delta) 436{ 437 if (stopEvent.scheduled()) 438 return; 439 --- 65 unchanged lines hidden --- | 437} 438 439void 440Scheduler::scheduleStop(bool finish_delta) 441{ 442 if (stopEvent.scheduled()) 443 return; 444 --- 65 unchanged lines hidden --- |