Deleted Added
sdiff udiff text old ( 12957:e54f9890363d ) new ( 12959:33d9a39e40a3 )
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

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

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), timeout(t)
41{
42 Tick when = scheduler.eventQueue().getCurTick() + timeout.value();
43 scheduler.eventQueue().schedule(&timeoutEvent, when);
44}
45
46SensitivityTimeout::~SensitivityTimeout()

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

75}
76
77void
78SensitivityEventAndList::notifyWork(Event *e)
79{
80 e->delSensitivity(this);
81 count++;
82 if (count == list->events.size())
83 process->satisfySensitivity(this);
84}
85
86SensitivityEventOrList::SensitivityEventOrList(
87 Process *p, const ::sc_core::sc_event_or_list *list) :
88 Sensitivity(p), list(list)
89{
90 for (auto e: list->events)
91 Event::getFromScEvent(e)->addSensitivity(this);

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

137void
138Process::suspend(bool inc_kids)
139{
140 if (inc_kids)
141 forEachKid([](Process *p) { p->suspend(true); });
142
143 if (!_suspended) {
144 _suspended = true;
145 _suspendedReady = false;
146 }
147
148 if (procKind() != ::sc_core::SC_METHOD_PROC_ &&
149 scheduler.current() == this) {
150 scheduler.yield();
151 }
152}
153
154void
155Process::resume(bool inc_kids)
156{
157 if (inc_kids)
158 forEachKid([](Process *p) { p->resume(true); });
159
160 if (_suspended) {
161 _suspended = false;
162 if (_suspendedReady)
163 ready();
164 _suspendedReady = false;
165 }
166}
167
168void
169Process::disable(bool inc_kids)
170{
171 if (inc_kids)
172 forEachKid([](Process *p) { p->disable(true); });

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

298
299void
300Process::setDynamic(Sensitivity *s)
301{
302 delete dynamicSensitivity;
303 dynamicSensitivity = s;
304}
305
306void
307Process::satisfySensitivity(Sensitivity *s)
308{
309 // If there's a dynamic sensitivity and this wasn't it, ignore.
310 if (dynamicSensitivity && dynamicSensitivity != s)
311 return;
312
313 setDynamic(nullptr);
314 ready();
315}
316
317void
318Process::ready()
319{
320 if (suspended())
321 _suspendedReady = true;
322 else
323 scheduler.ready(this);
324}
325
326Process::Process(const char *name, ProcessFuncWrapper *func, bool _dynamic) :
327 ::sc_core::sc_object(name), excWrapper(nullptr), func(func),
328 _running(false), _dynamic(_dynamic), _isUnwinding(false),
329 _terminated(false), _suspended(false), _disabled(false),
330 _syncReset(false), refCount(0), stackSize(::Fiber::DefaultStackSize),
331 dynamicSensitivity(nullptr)
332{
333 _newest = this;

--- 15 unchanged lines hidden ---