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#include "systemc/ext/core/sc_process_handle.hh"
36#include "systemc/ext/utils/sc_report_handler.hh"
37
38namespace sc_gem5
39{
40
41SensitivityTimeout::SensitivityTimeout(Process *p, ::sc_core::sc_time t) :
42 Sensitivity(p), timeoutEvent(this), time(t)
43{
44 Tick when = scheduler.getCurTick() + time.value();

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

198 if (inc_kids)
199 forEachKid([](Process *p) { p->kill(true); });
200
201 // If we're in the middle of unwinding, ignore the kill request.
202 if (_isUnwinding)
203 return;
204
205 // Update our state.
206 terminate();
207 _isUnwinding = true;
208
209 // Make sure this process isn't marked ready
210 popListNode();
211
212 // Inject the kill exception into this process if it's started.
213 if (!_needsStart)
214 injectException(killException);
215
216 _terminatedEvent.notify();
217}
218
219void
220Process::reset(bool inc_kids)
221{
222 // Propogate the reset to our children no matter what happens to us.
223 if (inc_kids)
224 forEachKid([](Process *p) { p->reset(true); });
225
226 // If we're in the middle of unwinding, ignore the reset request.
227 if (_isUnwinding)
228 return;
229
230
231 if (_needsStart) {
232 scheduler.runNow(this);
233 } else {
234 _isUnwinding = true;
235 injectException(resetException);
236 }
237
238 _resetEvent.notify();
239}
240
241void
242Process::throw_it(ExceptionWrapperBase &exc, bool inc_kids)
243{
244 if (inc_kids)
245 forEachKid([&exc](Process *p) { p->throw_it(exc, true); });
246
247 // Only inject an exception into threads that have started.
248 if (!_needsStart)
249 injectException(exc);
250}
251
252void
253Process::injectException(ExceptionWrapperBase &exc)
254{
255 excWrapper = &exc;
256 scheduler.runNow(this);
257};

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

299 reset = false;
300 try {
301 func->call();
302 } catch(const ::sc_core::sc_unwind_exception &exc) {
303 reset = exc.is_reset();
304 _isUnwinding = false;
305 }
306 } while (reset);
307}
308
309void
310Process::addStatic(PendingSensitivity *s)
311{
312 pendingStaticSensitivities.push_back(s);
313}
314

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

349 new ::sc_core::sc_report(*report));
350 } else {
351 _lastReport = nullptr;
352 }
353}
354
355::sc_core::sc_report *Process::lastReport() const { return _lastReport.get(); }
356
357Process::Process(const char *name, ProcessFuncWrapper *func, bool _dynamic) :
358 ::sc_core::sc_object(name), excWrapper(nullptr), func(func),
359 _needsStart(true), _dynamic(_dynamic), _isUnwinding(false),
360 _terminated(false), _suspended(false), _disabled(false),
361 _syncReset(false), refCount(0), stackSize(::Fiber::DefaultStackSize),
362 dynamicSensitivity(nullptr)
363{
364 _newest = this;
365}
366
367void
368Process::terminate()
369{
370 _terminated = true;
371 _suspendedReady = false;
372 _suspended = false;
373 _syncReset = false;
374 delete dynamicSensitivity;
375 dynamicSensitivity = nullptr;
376 for (auto s: staticSensitivities)
377 delete s;
378 staticSensitivities.clear();
379}
380
381Process *Process::_newest;
382
383void
384throw_it_wrapper(Process *p, ExceptionWrapperBase &exc, bool inc_kids)
385{
386 p->throw_it(exc, inc_kids);
387}
388
389} // namespace sc_gem5