Deleted Added
sdiff udiff text old ( 12997:cfc14d8f4725 ) new ( 12998:68d2c7538b82 )
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

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

27 * Authors: Gabe Black
28 */
29
30#include "systemc/core/process.hh"
31
32#include "base/logging.hh"
33#include "systemc/core/event.hh"
34#include "systemc/core/scheduler.hh"
35
36namespace sc_gem5
37{
38
39SensitivityTimeout::SensitivityTimeout(Process *p, ::sc_core::sc_time t) :
40 Sensitivity(p), timeoutEvent(this), time(t)
41{
42 Tick when = scheduler.getCurTick() + time.value();

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

196 if (inc_kids)
197 forEachKid([](Process *p) { p->kill(true); });
198
199 // If we're in the middle of unwinding, ignore the kill request.
200 if (_isUnwinding)
201 return;
202
203 // Update our state.
204 _terminated = true;
205 _isUnwinding = true;
206 _suspendedReady = false;
207 _suspended = false;
208 _syncReset = false;
209
210 // Inject the kill exception into this process.
211 injectException(killException);
212
213 _terminatedEvent.notify();
214}
215
216void
217Process::reset(bool inc_kids)
218{
219 // Propogate the reset to our children no matter what happens to us.
220 if (inc_kids)
221 forEachKid([](Process *p) { p->reset(true); });
222
223 // If we're in the middle of unwinding, ignore the reset request.
224 if (_isUnwinding)
225 return;
226
227 // Update our state.
228 _isUnwinding = true;
229
230 // Inject the reset exception into this process.
231 injectException(resetException);
232
233 _resetEvent.notify();
234}
235
236void
237Process::throw_it(ExceptionWrapperBase &exc, bool inc_kids)
238{
239 if (inc_kids)
240 forEachKid([&exc](Process *p) { p->throw_it(exc, true); });
241}
242
243void
244Process::injectException(ExceptionWrapperBase &exc)
245{
246 excWrapper = &exc;
247 scheduler.runNow(this);
248};

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

290 reset = false;
291 try {
292 func->call();
293 } catch(const ::sc_core::sc_unwind_exception &exc) {
294 reset = exc.is_reset();
295 _isUnwinding = false;
296 }
297 } while (reset);
298 _terminated = true;
299}
300
301void
302Process::addStatic(PendingSensitivity *s)
303{
304 pendingStaticSensitivities.push_back(s);
305}
306

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

341 new ::sc_core::sc_report(*report));
342 } else {
343 _lastReport = nullptr;
344 }
345}
346
347::sc_core::sc_report *Process::lastReport() const { return _lastReport.get(); }
348
349Process::Process(const char *name, ProcessFuncWrapper *func,
350 bool _dynamic, bool needs_start) :
351 ::sc_core::sc_object(name), excWrapper(nullptr), func(func),
352 _needsStart(needs_start), _dynamic(_dynamic), _isUnwinding(false),
353 _terminated(false), _suspended(false), _disabled(false),
354 _syncReset(false), refCount(0), stackSize(::Fiber::DefaultStackSize),
355 dynamicSensitivity(nullptr)
356{
357 _newest = this;
358}
359
360Process *Process::_newest;
361
362void
363throw_it_wrapper(Process *p, ExceptionWrapperBase &exc, bool inc_kids)
364{
365 p->throw_it(exc, inc_kids);
366}
367
368} // namespace sc_gem5