createProcess()
{
p = new Method(name.c_str(), &funcWrapper, true);
+ p->dontInitialize(true);
scheduler.reg(p);
- scheduler.dontInitialize(p);
}
~ClockTick()
_syncReset = false;
}
-void
-Process::dontInitialize()
-{
- scheduler.dontInitialize(this);
-}
-
void
Process::finalize()
{
Process::Process(const char *name, ProcessFuncWrapper *func, bool internal) :
::sc_core::sc_process_b(name), excWrapper(nullptr), func(func),
- _internal(internal), _timedOut(false), _needsStart(true),
- _isUnwinding(false), _terminated(false), _suspended(false),
- _disabled(false), _syncReset(false), refCount(0),
+ _internal(internal), _timedOut(false), _dontInitialize(false),
+ _needsStart(true), _isUnwinding(false), _terminated(false),
+ _suspended(false), _disabled(false), _syncReset(false), refCount(0),
stackSize(::Fiber::DefaultStackSize), dynamicSensitivity(nullptr)
{
_dynamic =
const ::sc_core::sc_event &resetEvent() { return _resetEvent; }
const ::sc_core::sc_event &terminatedEvent() { return _terminatedEvent; }
- // This should only be called before initialization.
- void dontInitialize();
-
void setStackSize(size_t size) { stackSize = size; }
void finalize();
bool timedOut() { return _timedOut; }
void timedOut(bool to) { _timedOut = to; }
+ bool dontInitialize() { return _dontInitialize; }
+ void dontInitialize(bool di) { _dontInitialize = di; }
+
protected:
Process(const char *name, ProcessFuncWrapper *func, bool internal=false);
// Needed to support the deprecated "timed_out" function.
bool _timedOut;
+ bool _dontInitialize;
+
bool _needsStart;
bool _dynamic;
bool _isUnwinding;
return nullptr;
}
scheduler.reg(p);
- p->dontInitialize();
+ p->dontInitialize(true);
return p;
}
void
sc_module::dont_initialize()
{
- ::sc_gem5::Process::newest()->dontInitialize();
+ ::sc_gem5::Process::newest()->dontInitialize(true);
}
void
else
proc = new Thread(name, func);
+ proc->dontInitialize(dontInitialize);
+
if (opts) {
for (auto e: opts->_events)
proc->addStatic(new PendingSensitivityEvent(proc, e));
scheduler.reg(proc);
- if (dontInitialize)
- scheduler.dontInitialize(proc);
-
return proc;
}
deschedule(&maxTickEvent);
Process *p;
- while ((p = toFinalize.getNext()))
- p->popListNode();
while ((p = initList.getNext()))
p->popListNode();
while ((p = readyListMethods.getNext()))
void
Scheduler::initPhase()
{
- for (Process *p = toFinalize.getNext(); p; p = toFinalize.getNext()) {
+ for (Process *p = initList.getNext(); p; p = initList.getNext()) {
p->finalize();
p->popListNode();
- if (!p->hasStaticSensitivities() && !p->internal()) {
- SC_REPORT_WARNING(
- "(W558) disable() or dont_initialize() called on process "
- "with no static sensitivity, it will be orphaned",
- p->name());
+ if (p->dontInitialize()) {
+ if (!p->hasStaticSensitivities() && !p->internal()) {
+ SC_REPORT_WARNING(
+ "(W558) disable() or dont_initialize() called on "
+ "process with no static sensitivity, it will be "
+ "orphaned", p->name());
+ }
+ } else {
+ p->ready();
}
}
- for (Process *p = initList.getNext(); p; p = initList.getNext()) {
- p->finalize();
- p->popListNode();
- p->ready();
- }
-
runUpdate();
runDelta();
if (initDone) {
// If we're past initialization, finalize static sensitivity.
p->finalize();
- // Mark the process as ready.
- p->ready();
+ // If not marked as dontInitialize, mark as ready.
+ if (!p->dontInitialize())
+ p->ready();
} else {
// Otherwise, record that this process should be initialized once we
// get there.
}
}
-void
-Scheduler::dontInitialize(Process *p)
-{
- if (initDone) {
- // Pop this process off of the ready list.
- p->popListNode();
- } else {
- // Push this process onto the list of processes which still need
- // their static sensitivity to be finalized. That implicitly pops it
- // off the list of processes to be initialized/marked ready.
- toFinalize.pushLast(p);
- }
-}
-
void
Scheduler::yield()
{
{
bool was_ready;
if (initDone) {
- // After initialization, the only list we can be on is the ready list.
+ // After initialization, check if we're on a ready list.
was_ready = (p->nextListNode != nullptr);
p->popListNode();
} else {
- // Check the ready lists to see if we find this process.
- was_ready = listContains(&readyListMethods, p) ||
- listContains(&readyListThreads, p);
- if (was_ready)
- toFinalize.pushLast(p);
+ // Nothing is ready before init.
+ was_ready = false;
}
return was_ready;
}
// Register a process with the scheduler.
void reg(Process *p);
- // Tell the scheduler not to initialize a process.
- void dontInitialize(Process *p);
-
// Run the next process, if there is one.
void yield();
bool runOnce;
ProcessList initList;
- ProcessList toFinalize;
ProcessList *readyList;
ProcessList readyListMethods;