diff options
-rw-r--r-- | src/systemc/core/channel.cc | 3 | ||||
-rw-r--r-- | src/systemc/core/scheduler.cc | 13 | ||||
-rw-r--r-- | src/systemc/core/scheduler.hh | 6 |
3 files changed, 20 insertions, 2 deletions
diff --git a/src/systemc/core/channel.cc b/src/systemc/core/channel.cc index 04f158bea..4c731716d 100644 --- a/src/systemc/core/channel.cc +++ b/src/systemc/core/channel.cc @@ -54,8 +54,7 @@ Channel::requestUpdate() void Channel::asyncRequestUpdate() { - //TODO This should probably not request an update directly. - scheduler.requestUpdate(this); + scheduler.asyncRequestUpdate(this); } std::set<Channel *> allChannels; diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc index d06ddfb58..f1a78198d 100644 --- a/src/systemc/core/scheduler.cc +++ b/src/systemc/core/scheduler.cc @@ -258,6 +258,13 @@ Scheduler::requestUpdate(Channel *c) } void +Scheduler::asyncRequestUpdate(Channel *c) +{ + std::lock_guard<std::mutex> lock(asyncListMutex); + asyncUpdateList.pushLast(c); +} + +void Scheduler::scheduleReadyEvent() { // Schedule the evaluate and update phases. @@ -321,6 +328,12 @@ void Scheduler::runUpdate() { status(StatusUpdate); + { + std::lock_guard<std::mutex> lock(asyncListMutex); + Channel *channel; + while ((channel = asyncUpdateList.getNext()) != nullptr) + updateList.pushLast(channel); + } try { Channel *channel = updateList.getNext(); diff --git a/src/systemc/core/scheduler.hh b/src/systemc/core/scheduler.hh index 63f6ac35d..b576bec00 100644 --- a/src/systemc/core/scheduler.hh +++ b/src/systemc/core/scheduler.hh @@ -32,6 +32,7 @@ #include <functional> #include <map> +#include <mutex> #include <set> #include <vector> @@ -191,6 +192,8 @@ class Scheduler // Schedule an update for a given channel. void requestUpdate(Channel *c); + // Same as above, but may be called from a different thread. + void asyncRequestUpdate(Channel *c); // Run the given process immediately, preempting whatever may be running. void @@ -481,6 +484,9 @@ class Scheduler ChannelList updateList; + ChannelList asyncUpdateList; + std::mutex asyncListMutex; + std::map<::Event *, Tick> eventsToSchedule; std::set<TraceFile *> traceFiles; |