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

Change subject: systemc: Fill out process handle kill and reset mechanisms.
......................................................................

systemc: Fill out process handle kill and reset mechanisms.

Some flags were being updated too early, making the functions think
what they were about to do had already been done. Also, actually check
for and throw the exception installed in a process when it's next
supposed to run, and when injecting an exception schedule that other
process to run immediately.

Change-Id: I0856b69903699b2c66f9dc7f44942bbfe3cfdcc4
---
M src/systemc/core/process.cc
M src/systemc/core/scheduler.cc
2 files changed, 22 insertions(+), 13 deletions(-)



diff --git a/src/systemc/core/process.cc b/src/systemc/core/process.cc
index 678cb04..ec5c57c 100644
--- a/src/systemc/core/process.cc
+++ b/src/systemc/core/process.cc
@@ -108,15 +108,13 @@
 class UnwindExceptionReset : public ::sc_core::sc_unwind_exception
 {
   public:
-    const char *what() const throw() override { return "RESET"; }
-    bool is_reset() const override { return true; }
+    UnwindExceptionReset() { _isReset = true; }
 };

 class UnwindExceptionKill : public ::sc_core::sc_unwind_exception
 {
   public:
-    const char *what() const throw() override { return "KILL"; }
-    bool is_reset() const override { return false; }
+    UnwindExceptionKill() {}
 };

 template <typename T>
@@ -194,10 +192,6 @@
 void
 Process::kill(bool inc_kids)
 {
-    // Update our state.
-    _terminated = true;
-    _isUnwinding = true;
-
     // Propogate the kill to our children no matter what happens to us.
     if (inc_kids)
         forEachKid([](Process *p) { p->kill(true); });
@@ -206,6 +200,13 @@
     if (_isUnwinding)
         return;

+    // Update our state.
+    _terminated = true;
+    _isUnwinding = true;
+    _suspendedReady = false;
+    _suspended = false;
+    _syncReset = false;
+
     // Inject the kill exception into this process.
     injectException(killException);

@@ -215,9 +216,6 @@
 void
 Process::reset(bool inc_kids)
 {
-    // Update our state.
-    _isUnwinding = true;
-
     // Propogate the reset to our children no matter what happens to us.
     if (inc_kids)
         forEachKid([](Process *p) { p->reset(true); });
@@ -226,6 +224,9 @@
     if (_isUnwinding)
         return;

+    // Update our state.
+    _isUnwinding = true;
+
     // Inject the reset exception into this process.
     injectException(resetException);

@@ -243,7 +244,7 @@
 Process::injectException(ExceptionWrapperBase &exc)
 {
     excWrapper = &exc;
-    // Let this process preempt us.
+    scheduler.runNow(this);
 };

 void
@@ -289,8 +290,9 @@
         reset = false;
         try {
             func->call();
-        } catch(::sc_core::sc_unwind_exception exc) {
+        } catch(const ::sc_core::sc_unwind_exception &exc) {
             reset = exc.is_reset();
+            _isUnwinding = false;
         }
     } while (reset);
     _terminated = true;
diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc
index c2b5ec3..085602d 100644
--- a/src/systemc/core/scheduler.cc
+++ b/src/systemc/core/scheduler.cc
@@ -117,6 +117,13 @@
         if (_current && _current->needsStart())
             _current->run();
     }
+    if (_current && _current->excWrapper) {
+        // Make sure this isn't a method process.
+        assert(!_current->needsStart());
+        auto ew = _current->excWrapper;
+        _current->excWrapper = nullptr;
+        ew->throw_it();
+    }
 }

 void

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12046
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: I0856b69903699b2c66f9dc7f44942bbfe3cfdcc4
Gerrit-Change-Number: 12046
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