process.cc (12957:e54f9890363d) process.cc (12959:33d9a39e40a3)
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
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
39void
40Sensitivity::satisfy()
41{
42 warn_once("Ignoring suspended status for now.\n");
43 process->setDynamic(nullptr);
44 scheduler.ready(process);
45}
46
47SensitivityTimeout::SensitivityTimeout(Process *p, ::sc_core::sc_time t) :
48 Sensitivity(p), timeoutEvent(this), timeout(t)
49{
50 Tick when = scheduler.eventQueue().getCurTick() + timeout.value();
51 scheduler.eventQueue().schedule(&timeoutEvent, when);
52}
53
54SensitivityTimeout::~SensitivityTimeout()

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

83}
84
85void
86SensitivityEventAndList::notifyWork(Event *e)
87{
88 e->delSensitivity(this);
89 count++;
90 if (count == list->events.size())
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())
91 satisfy();
83 process->satisfySensitivity(this);
92}
93
94SensitivityEventOrList::SensitivityEventOrList(
95 Process *p, const ::sc_core::sc_event_or_list *list) :
96 Sensitivity(p), list(list)
97{
98 for (auto e: list->events)
99 Event::getFromScEvent(e)->addSensitivity(this);

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

145void
146Process::suspend(bool inc_kids)
147{
148 if (inc_kids)
149 forEachKid([](Process *p) { p->suspend(true); });
150
151 if (!_suspended) {
152 _suspended = true;
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;
153 //TODO Suspend this process.
145 _suspendedReady = false;
154 }
155
156 if (procKind() != ::sc_core::SC_METHOD_PROC_ &&
157 scheduler.current() == this) {
158 scheduler.yield();
159 }
160}
161
162void
163Process::resume(bool inc_kids)
164{
165 if (inc_kids)
166 forEachKid([](Process *p) { p->resume(true); });
167
168 if (_suspended) {
169 _suspended = 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;
170 //TODO Resume this process.
162 if (_suspendedReady)
163 ready();
164 _suspendedReady = false;
171 }
172}
173
174void
175Process::disable(bool inc_kids)
176{
177 if (inc_kids)
178 forEachKid([](Process *p) { p->disable(true); });

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

304
305void
306Process::setDynamic(Sensitivity *s)
307{
308 delete dynamicSensitivity;
309 dynamicSensitivity = s;
310}
311
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
312Process::Process(const char *name, ProcessFuncWrapper *func, bool _dynamic) :
313 ::sc_core::sc_object(name), excWrapper(nullptr), func(func),
314 _running(false), _dynamic(_dynamic), _isUnwinding(false),
315 _terminated(false), _suspended(false), _disabled(false),
316 _syncReset(false), refCount(0), stackSize(::Fiber::DefaultStackSize),
317 dynamicSensitivity(nullptr)
318{
319 _newest = this;

--- 15 unchanged lines hidden ---
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 ---