Gabe Black has submitted this change and it was merged. ( https://gem5-review.googlesource.com/c/public/gem5/+/11715 )

Change subject: systemc: Handle suspended processes and handle sensitivity overload.
......................................................................

systemc: Handle suspended processes and handle sensitivity overload.

This change keeps track of whether a process would have become ready
but was suspended so that it can become ready when the process is
resumed.

Also, this makes a process ignore its static sensitivity while a
dynamic sensitivity is in place.

Change-Id: If3f6c62f370051e574f81bf227746db8c43527e2
Reviewed-on: https://gem5-review.googlesource.com/11715
Reviewed-by: Gabe Black <[email protected]>
Maintainer: Gabe Black <[email protected]>
---
M src/systemc/core/process.cc
M src/systemc/core/process.hh
M src/systemc/core/scheduler.cc
3 files changed, 39 insertions(+), 15 deletions(-)

Approvals:
  Gabe Black: Looks good to me, approved; Looks good to me, approved



diff --git a/src/systemc/core/process.cc b/src/systemc/core/process.cc
index a949c9d..63d2ff9 100644
--- a/src/systemc/core/process.cc
+++ b/src/systemc/core/process.cc
@@ -36,14 +36,6 @@
 namespace sc_gem5
 {

-void
-Sensitivity::satisfy()
-{
-    warn_once("Ignoring suspended status for now.\n");
-    process->setDynamic(nullptr);
-    scheduler.ready(process);
-}
-
 SensitivityTimeout::SensitivityTimeout(Process *p, ::sc_core::sc_time t) :
     Sensitivity(p), timeoutEvent(this), timeout(t)
 {
@@ -88,7 +80,7 @@
     e->delSensitivity(this);
     count++;
     if (count == list->events.size())
-        satisfy();
+        process->satisfySensitivity(this);
 }

 SensitivityEventOrList::SensitivityEventOrList(
@@ -150,7 +142,7 @@

     if (!_suspended) {
         _suspended = true;
-        //TODO Suspend this process.
+        _suspendedReady = false;
     }

     if (procKind() != ::sc_core::SC_METHOD_PROC_ &&
@@ -167,7 +159,9 @@

     if (_suspended) {
         _suspended = false;
-        //TODO Resume this process.
+        if (_suspendedReady)
+            ready();
+        _suspendedReady = false;
     }
 }

@@ -309,6 +303,26 @@
     dynamicSensitivity = s;
 }

+void
+Process::satisfySensitivity(Sensitivity *s)
+{
+    // If there's a dynamic sensitivity and this wasn't it, ignore.
+    if (dynamicSensitivity && dynamicSensitivity != s)
+        return;
+
+    setDynamic(nullptr);
+    ready();
+}
+
+void
+Process::ready()
+{
+    if (suspended())
+        _suspendedReady = true;
+    else
+        scheduler.ready(this);
+}
+
Process::Process(const char *name, ProcessFuncWrapper *func, bool _dynamic) :
     ::sc_core::sc_object(name), excWrapper(nullptr), func(func),
     _running(false), _dynamic(_dynamic), _isUnwinding(false),
diff --git a/src/systemc/core/process.hh b/src/systemc/core/process.hh
index cd92992..579ea60 100644
--- a/src/systemc/core/process.hh
+++ b/src/systemc/core/process.hh
@@ -51,13 +51,12 @@
 {
   protected:
     Process *process;
-    void satisfy();

   public:
     Sensitivity(Process *p) : process(p) {}
     virtual ~Sensitivity() {}

-    virtual void notifyWork(Event *e) { satisfy(); }
+    virtual void notifyWork(Event *e);
     void notify(Event *e);
     void notify() { notify(nullptr); }

@@ -290,6 +289,10 @@
     void addStatic(PendingSensitivity *);
     void setDynamic(Sensitivity *);

+    void satisfySensitivity(Sensitivity *);
+
+    void ready();
+
     virtual Fiber *fiber() { return Fiber::primaryFiber(); }

     static Process *newest() { return _newest; }
@@ -317,6 +320,7 @@
     bool _terminated;

     bool _suspended;
+    bool _suspendedReady;
     bool _disabled;

     bool _syncReset;
@@ -332,6 +336,12 @@
 };

 inline void
+Sensitivity::notifyWork(Event *e)
+{
+    process->satisfySensitivity(this);
+}
+
+inline void
 Sensitivity::notify(Event *e)
 {
     if (!process->disabled())
diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc
index 8ea090f..230ed0a 100644
--- a/src/systemc/core/scheduler.cc
+++ b/src/systemc/core/scheduler.cc
@@ -51,7 +51,7 @@

     for (Process *p = initList.getNext(); p; p = initList.getNext()) {
         p->finalize();
-        ready(p);
+        p->ready();
     }

     initReady = true;
@@ -64,7 +64,7 @@
         // If we're past initialization, finalize static sensitivity.
         p->finalize();
         // Mark the process as ready.
-        ready(p);
+        p->ready();
     } else {
// Otherwise, record that this process should be initialized once we
         // get there.

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/11715
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: If3f6c62f370051e574f81bf227746db8c43527e2
Gerrit-Change-Number: 11715
Gerrit-PatchSet: 8
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Matthias Jung <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to