From 8b8b75092a2ef84a98132518e5da55e559e942f7 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 19 Jul 2018 17:32:34 -0700 Subject: [PATCH] systemc: Handle event notifications scheduled before sc_start. After sc_start is called, gem5 has run far enough to have an event queue to schedule the notification events on. Before then, it's still legal to request a timed notification. The scheduler should keep track of those requests, and once an event queue is available it should add them to it. Change-Id: Ie7445b1f2e616f4bd36044a09dbef9e1d12d7350 Reviewed-on: https://gem5-review.googlesource.com/12036 Reviewed-by: Gabe Black Maintainer: Gabe Black --- src/systemc/core/scheduler.cc | 4 ++++ src/systemc/core/scheduler.hh | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc index 6bb67d136..5174627d0 100644 --- a/src/systemc/core/scheduler.cc +++ b/src/systemc/core/scheduler.cc @@ -60,6 +60,10 @@ Scheduler::prepareForInit() p->ready(); } + for (auto ets: eventsToSchedule) + eq->schedule(ets.first, ets.second); + eventsToSchedule.clear(); + if (_started) eq->schedule(&maxTickEvent, maxTick); diff --git a/src/systemc/core/scheduler.hh b/src/systemc/core/scheduler.hh index 3ac7f419f..73d660e9e 100644 --- a/src/systemc/core/scheduler.hh +++ b/src/systemc/core/scheduler.hh @@ -187,7 +187,11 @@ class Scheduler schedule(::Event *event, Tick tick) { pendingTicks[tick]++; - eq->schedule(event, tick); + + if (initReady) + eq->schedule(event, tick); + else + eventsToSchedule[event] = tick; } // For descheduling delayed/timed notifications/timeouts. @@ -197,7 +201,11 @@ class Scheduler auto it = pendingTicks.find(event->when()); if (--it->second == 0) pendingTicks.erase(it); - eq->deschedule(event); + + if (initReady) + eq->deschedule(event); + else + eventsToSchedule.erase(event); } // Tell the scheduler than an event fired for bookkeeping purposes. @@ -302,6 +310,8 @@ class Scheduler ProcessList readyList; ChannelList updateList; + + std::map<::Event *, Tick> eventsToSchedule; }; extern Scheduler scheduler; -- 2.30.2