summaryrefslogtreecommitdiff
path: root/src/systemc/core/process.cc
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-07-26 15:13:52 -0700
committerGabe Black <gabeblack@google.com>2018-09-11 21:49:01 +0000
commit6a198f29234a6a037f73cefd15f784bd18017d1a (patch)
treeb2d0dcdb3e326d6be8007eedcb81789a1aa892e3 /src/systemc/core/process.cc
parentea6b370fe79e043ed949033f9f3a4306b668aa94 (diff)
downloadgem5-6a198f29234a6a037f73cefd15f784bd18017d1a.tar.xz
systemc: Adjust process status tracking to improve kill/reset support.
This change rearranges how process status is tracked so that the kill and reset mechanisms work in more circumstances and more like they're supposed to according to the spec. This makes another test or two pass. Change-Id: Ie2a683a796155a82092109d5bb45f07c84e06c76 Reviewed-on: https://gem5-review.googlesource.com/12049 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/core/process.cc')
-rw-r--r--src/systemc/core/process.cc49
1 files changed, 35 insertions, 14 deletions
diff --git a/src/systemc/core/process.cc b/src/systemc/core/process.cc
index 6a0e7d5a3..6b4c42766 100644
--- a/src/systemc/core/process.cc
+++ b/src/systemc/core/process.cc
@@ -32,6 +32,8 @@
#include "base/logging.hh"
#include "systemc/core/event.hh"
#include "systemc/core/scheduler.hh"
+#include "systemc/ext/core/sc_process_handle.hh"
+#include "systemc/ext/utils/sc_report_handler.hh"
namespace sc_gem5
{
@@ -201,14 +203,15 @@ Process::kill(bool inc_kids)
return;
// Update our state.
- _terminated = true;
+ terminate();
_isUnwinding = true;
- _suspendedReady = false;
- _suspended = false;
- _syncReset = false;
- // Inject the kill exception into this process.
- injectException(killException);
+ // Make sure this process isn't marked ready
+ popListNode();
+
+ // Inject the kill exception into this process if it's started.
+ if (!_needsStart)
+ injectException(killException);
_terminatedEvent.notify();
}
@@ -224,11 +227,13 @@ Process::reset(bool inc_kids)
if (_isUnwinding)
return;
- // Update our state.
- _isUnwinding = true;
- // Inject the reset exception into this process.
- injectException(resetException);
+ if (_needsStart) {
+ scheduler.runNow(this);
+ } else {
+ _isUnwinding = true;
+ injectException(resetException);
+ }
_resetEvent.notify();
}
@@ -238,6 +243,10 @@ Process::throw_it(ExceptionWrapperBase &exc, bool inc_kids)
{
if (inc_kids)
forEachKid([&exc](Process *p) { p->throw_it(exc, true); });
+
+ // Only inject an exception into threads that have started.
+ if (!_needsStart)
+ injectException(exc);
}
void
@@ -295,7 +304,6 @@ Process::run()
_isUnwinding = false;
}
} while (reset);
- _terminated = true;
}
void
@@ -346,10 +354,9 @@ Process::lastReport(::sc_core::sc_report *report)
::sc_core::sc_report *Process::lastReport() const { return _lastReport.get(); }
-Process::Process(const char *name, ProcessFuncWrapper *func,
- bool _dynamic, bool needs_start) :
+Process::Process(const char *name, ProcessFuncWrapper *func, bool _dynamic) :
::sc_core::sc_object(name), excWrapper(nullptr), func(func),
- _needsStart(needs_start), _dynamic(_dynamic), _isUnwinding(false),
+ _needsStart(true), _dynamic(_dynamic), _isUnwinding(false),
_terminated(false), _suspended(false), _disabled(false),
_syncReset(false), refCount(0), stackSize(::Fiber::DefaultStackSize),
dynamicSensitivity(nullptr)
@@ -357,6 +364,20 @@ Process::Process(const char *name, ProcessFuncWrapper *func,
_newest = this;
}
+void
+Process::terminate()
+{
+ _terminated = true;
+ _suspendedReady = false;
+ _suspended = false;
+ _syncReset = false;
+ delete dynamicSensitivity;
+ dynamicSensitivity = nullptr;
+ for (auto s: staticSensitivities)
+ delete s;
+ staticSensitivities.clear();
+}
+
Process *Process::_newest;
void