process.cc (12952:94fca7e8120b) | process.cc (12953:ddfd5e4643a9) |
---|---|
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" | 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" |
|
31 32namespace sc_gem5 33{ 34 35class UnwindExceptionReset : public ::sc_core::sc_unwind_exception 36{ 37 public: 38 const char *what() const throw() override { return "RESET"; } --- 35 unchanged lines hidden (view full) --- 74 if (inc_kids) 75 forEachKid([](Process *p) { p->suspend(true); }); 76 77 if (!_suspended) { 78 _suspended = true; 79 //TODO Suspend this process. 80 } 81 | 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 |
82 if (procKind() != ::sc_core::SC_METHOD_PROC_ /* && we're running */) { 83 // We suspended this thread or cthread. Stop running. | 83 if (procKind() != ::sc_core::SC_METHOD_PROC_ && 84 scheduler.current() == this) { 85 scheduler.yield(); |
84 } 85} 86 87void 88Process::resume(bool inc_kids) 89{ 90 if (inc_kids) 91 forEachKid([](Process *p) { p->resume(true); }); --- 92 unchanged lines hidden (view full) --- 184{ 185 if (inc_kids) 186 forEachKid([](Process *p) { p->syncResetOff(true); }); 187 188 _syncReset = false; 189} 190 191void | 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 |
192Thread::throw_it(ExceptionWrapperBase &exc, bool inc_kids) | 194Process::run() |
193{ | 195{ |
194 Process::throw_it(exc, inc_kids); | 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} |
195 | 208 |
196 if (_terminated) 197 return; 198 199 injectException(exc); | 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); |
200} 201 | 218} 219 |
220Process *Process::_newest; 221 |
|
202void 203throw_it_wrapper(Process *p, ExceptionWrapperBase &exc, bool inc_kids) 204{ 205 p->throw_it(exc, inc_kids); 206} 207 208} // namespace sc_gem5 | 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 |