Deleted Added
sdiff udiff text old ( 12952:94fca7e8120b ) new ( 12953:ddfd5e4643a9 )
full compact
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright

--- 14 unchanged lines hidden (view full) ---

23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * Authors: Gabe Black
28 */
29
30#include "systemc/core/process.hh"
31#include "systemc/core/scheduler.hh"
32
33namespace sc_gem5
34{
35
36class UnwindExceptionReset : public ::sc_core::sc_unwind_exception
37{
38 public:
39 const char *what() const throw() override { return "RESET"; }

--- 35 unchanged lines hidden (view full) ---

75 if (inc_kids)
76 forEachKid([](Process *p) { p->suspend(true); });
77
78 if (!_suspended) {
79 _suspended = true;
80 //TODO Suspend this process.
81 }
82
83 if (procKind() != ::sc_core::SC_METHOD_PROC_ &&
84 scheduler.current() == this) {
85 scheduler.yield();
86 }
87}
88
89void
90Process::resume(bool inc_kids)
91{
92 if (inc_kids)
93 forEachKid([](Process *p) { p->resume(true); });

--- 92 unchanged lines hidden (view full) ---

186{
187 if (inc_kids)
188 forEachKid([](Process *p) { p->syncResetOff(true); });
189
190 _syncReset = false;
191}
192
193void
194Process::run()
195{
196 _running = true;
197 bool reset;
198 do {
199 reset = false;
200 try {
201 func->call();
202 } catch(::sc_core::sc_unwind_exception exc) {
203 reset = exc.is_reset();
204 }
205 } while (reset);
206 _running = false;
207}
208
209Process::Process(const char *name, ProcessFuncWrapper *func, bool _dynamic) :
210 ::sc_core::sc_object(name), excWrapper(nullptr), func(func),
211 _running(false), _dynamic(_dynamic), _isUnwinding(false),
212 _terminated(false), _suspended(false), _disabled(false),
213 _syncReset(false), refCount(0), stackSize(::Fiber::DefaultStackSize)
214{
215 _newest = this;
216 if (!_dynamic)
217 scheduler.init(this);
218}
219
220Process *Process::_newest;
221
222void
223throw_it_wrapper(Process *p, ExceptionWrapperBase &exc, bool inc_kids)
224{
225 p->throw_it(exc, inc_kids);
226}
227
228} // namespace sc_gem5