From f2ab5e7a9e11783da3b9d7338775cf4b5fe2c29c Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 16 Jul 2018 16:14:33 -0700 Subject: systemc: Implement the sensitivity mechanism. This change lets processes be sensitive to events, timeouts, etc. Change-Id: If30a256dfa8a2e92192c1f9c96b48e2aa28ec27e Reviewed-on: https://gem5-review.googlesource.com/11713 Reviewed-by: Gabe Black Maintainer: Gabe Black --- src/systemc/core/scheduler.cc | 46 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) (limited to 'src/systemc/core/scheduler.cc') diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc index 17e7dc43e..8ea090f57 100644 --- a/src/systemc/core/scheduler.cc +++ b/src/systemc/core/scheduler.cc @@ -38,14 +38,52 @@ namespace sc_gem5 Scheduler::Scheduler() : eq(nullptr), readyEvent(this, false, EventBase::Default_Pri + 1), - _numCycles(0), _current(nullptr) + _numCycles(0), _current(nullptr), initReady(false) {} void -Scheduler::initToReady() +Scheduler::prepareForInit() { - while (!initList.empty()) - ready(initList.getNext()); + for (Process *p = toFinalize.getNext(); p; p = toFinalize.getNext()) { + p->finalize(); + p->popListNode(); + } + + for (Process *p = initList.getNext(); p; p = initList.getNext()) { + p->finalize(); + ready(p); + } + + initReady = true; +} + +void +Scheduler::reg(Process *p) +{ + if (initReady) { + // If we're past initialization, finalize static sensitivity. + p->finalize(); + // Mark the process as ready. + ready(p); + } else { + // Otherwise, record that this process should be initialized once we + // get there. + initList.pushLast(p); + } +} + +void +Scheduler::dontInitialize(Process *p) +{ + if (initReady) { + // 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 -- cgit v1.2.3