summaryrefslogtreecommitdiff
path: root/src/systemc/core/scheduler.cc
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-08-17 17:30:31 -0700
committerGabe Black <gabeblack@google.com>2018-09-25 23:51:31 +0000
commita56dbe9338272273ac576514685e1c01ded173a2 (patch)
tree3184fc6bb33a20268c12ea8bd3f2b4c5330f5656 /src/systemc/core/scheduler.cc
parentdd30c7ef763e01e52db5d6a9f9b0c9309fab9d4f (diff)
downloadgem5-a56dbe9338272273ac576514685e1c01ded173a2.tar.xz
systemc: Make sure sc_start waits for simulation even when starving.
Even if the simulation would return from sc_start immediately because of starvation, this change ensures that sc_start gives control back to gem5 so that the scheduler will have a chance to set up sensitivities, etc., before things get torn down. Change-Id: I39b1fd704fcbe12c299cad9dbd30258e8fe9d032 Reviewed-on: https://gem5-review.googlesource.com/12218 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/core/scheduler.cc')
-rw-r--r--src/systemc/core/scheduler.cc18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc
index 77015dd46..e18855c4d 100644
--- a/src/systemc/core/scheduler.cc
+++ b/src/systemc/core/scheduler.cc
@@ -74,8 +74,11 @@ Scheduler::initPhase()
eq->schedule(ets.first, ets.second);
eventsToSchedule.clear();
- if (_started)
+ if (_started) {
+ if (starved() && !runToTime)
+ scheduleStarvationEvent();
eq->schedule(&maxTickEvent, maxTick);
+ }
initDone = true;
}
@@ -170,9 +173,11 @@ void
Scheduler::scheduleStarvationEvent()
{
if (!starvationEvent.scheduled()) {
- panic_if(!eq, "Need to schedule starvation event, "
- "but no event manager.\n");
- eq->schedule(&starvationEvent, eq->getCurTick());
+ Tick now = getCurTick();
+ if (initDone)
+ eq->schedule(&starvationEvent, now);
+ else
+ eventsToSchedule[&starvationEvent] = now;
if (readyEvent.scheduled())
eq->deschedule(&readyEvent);
}
@@ -249,10 +254,9 @@ Scheduler::start(Tick max_tick, bool run_to_time)
maxTick = max_tick;
- if (starved() && !runToTime)
- return;
-
if (initDone) {
+ if (starved() && !runToTime)
+ scheduleStarvationEvent();
kernel->status(::sc_core::SC_RUNNING);
eq->schedule(&maxTickEvent, maxTick);
}