Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/12219

Change subject: systemc: Generalize gem5 style event scheduling.
......................................................................

systemc: Generalize gem5 style event scheduling.

These events are either scheduled directly, or if no event queue is
yet available they're recorded in a map to schedule later. Since this
was used in a few places (and should have been used for the ready
event), this change moves it into some common functions which remove
some duplication and abstract away this detail.

Change-Id: I4320d7296f4f72344539b2b4b2564a6a27576dd8
---
M src/systemc/core/scheduler.cc
M src/systemc/core/scheduler.hh
2 files changed, 31 insertions(+), 21 deletions(-)



diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc
index e18855c..cdebd99 100644
--- a/src/systemc/core/scheduler.cc
+++ b/src/systemc/core/scheduler.cc
@@ -77,7 +77,7 @@
     if (_started) {
         if (starved() && !runToTime)
             scheduleStarvationEvent();
-        eq->schedule(&maxTickEvent, maxTick);
+        kernel->status(::sc_core::SC_RUNNING);
     }

     initDone = true;
@@ -153,8 +153,7 @@
 Scheduler::requestUpdate(Channel *c)
 {
     updateList.pushLast(c);
-    if (eq)
-        scheduleReadyEvent();
+    scheduleReadyEvent();
 }

 void
@@ -162,10 +161,9 @@
 {
     // Schedule the evaluate and update phases.
     if (!readyEvent.scheduled()) {
-        panic_if(!eq, "Need to schedule ready, but no event manager.\n");
-        eq->schedule(&readyEvent, eq->getCurTick());
+        schedule(&readyEvent);
         if (starvationEvent.scheduled())
-            eq->deschedule(&starvationEvent);
+            deschedule(&starvationEvent);
     }
 }

@@ -173,13 +171,9 @@
 Scheduler::scheduleStarvationEvent()
 {
     if (!starvationEvent.scheduled()) {
-        Tick now = getCurTick();
-        if (initDone)
-            eq->schedule(&starvationEvent, now);
-        else
-            eventsToSchedule[&starvationEvent] = now;
+        schedule(&starvationEvent);
         if (readyEvent.scheduled())
-            eq->deschedule(&readyEvent);
+            deschedule(&readyEvent);
     }
 }

@@ -258,9 +252,10 @@
         if (starved() && !runToTime)
             scheduleStarvationEvent();
         kernel->status(::sc_core::SC_RUNNING);
-        eq->schedule(&maxTickEvent, maxTick);
     }

+    schedule(&maxTickEvent, maxTick);
+
     // Return to gem5 to let it run events, etc.
     Fiber::primaryFiber()->run();

diff --git a/src/systemc/core/scheduler.hh b/src/systemc/core/scheduler.hh
index 2843b68..c22bdf8 100644
--- a/src/systemc/core/scheduler.hh
+++ b/src/systemc/core/scheduler.hh
@@ -225,10 +225,7 @@
         TimeSlot *&ts = timeSlots[tick];
         if (!ts) {
             ts = new TimeSlot;
-            if (initDone)
-                eq->schedule(ts, tick);
-            else
-                eventsToSchedule[ts] = tick;
+            schedule(ts, tick);
         }
         ts->events.insert(event);
     }
@@ -255,10 +252,7 @@

// If no more events are happening at this time slot, get rid of it.
         if (events.empty()) {
-            if (initDone)
-                eq->deschedule(ts);
-            else
-                eventsToSchedule.erase(ts);
+            deschedule(ts);
             timeSlots.erase(tsit);
         }
     }
@@ -328,6 +322,27 @@

     EventQueue *eq;

+    // For gem5 style events.
+    void
+    schedule(::Event *event, Tick tick)
+    {
+        if (initDone)
+            eq->schedule(event, tick);
+        else
+            eventsToSchedule[event] = tick;
+    }
+
+    void schedule(::Event *event) { schedule(event, getCurTick()); }
+
+    void
+    deschedule(::Event *event)
+    {
+        if (initDone)
+            eq->deschedule(event);
+        else
+            eventsToSchedule.erase(event);
+    }
+
     ScEvents deltas;
     TimeSlots timeSlots;


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12219
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I4320d7296f4f72344539b2b4b2564a6a27576dd8
Gerrit-Change-Number: 12219
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to