systemc: Make sure methods aren't restarted by yield.
authorGabe Black <gabeblack@google.com>
Sat, 25 Aug 2018 00:58:10 +0000 (17:58 -0700)
committerGabe Black <gabeblack@google.com>
Wed, 26 Sep 2018 00:01:55 +0000 (00:01 +0000)
Methods may need to yield control to other Processes when throwing
them exceptions. In that case, we need to keep track of the fact that
the method doesn't need to be restarted when it resumes within yield.

Change-Id: I829c387d6ddb563b2957db47e55adadbbe6bc51a
Reviewed-on: https://gem5-review.googlesource.com/12265
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>

src/systemc/core/process.cc
src/systemc/core/process.hh
src/systemc/core/scheduler.cc

index 1a101f749f5fe5b03ae6c69050b48efac5b90e8f..94e49a8afd2064bbf55581cb3d000c8ab8243a82 100644 (file)
@@ -320,6 +320,7 @@ Process::run()
             _isUnwinding = false;
         }
     } while (reset);
+    needsStart(true);
 }
 
 void
index 17f417b6e26183d813db9fda85b21183da84991d..0cb3e3c01c3e06fe7afd5f6b54286d8da7dbd4db 100644 (file)
@@ -271,6 +271,7 @@ class Process : public ::sc_core::sc_process_b, public ListNode
   public:
     virtual ::sc_core::sc_curr_proc_kind procKind() const = 0;
     bool needsStart() const { return _needsStart; }
+    void needsStart(bool ns) { _needsStart = ns; }
     bool dynamic() const { return _dynamic; }
     bool isUnwinding() const { return _isUnwinding; }
     void isUnwinding(bool v) { _isUnwinding = v; }
index 2dc3aa74c12c8502587b1aaf90270dac3b905bf8..7851bac67e8f0d5963b35b028ce1e71759a5318a 100644 (file)
@@ -174,8 +174,10 @@ Scheduler::yield()
         // Fibers which aren't running should be parked at this line.
         _current->fiber()->run();
         // If the current process needs to be manually started, start it.
-        if (_current && _current->needsStart())
+        if (_current && _current->needsStart()) {
+            _current->needsStart(false);
             _current->run();
+        }
     }
     if (_current && _current->excWrapper) {
         // Make sure this isn't a method process.