diff options
author | Nilay Vaish <nilay@cs.wisc.edu> | 2012-11-16 10:27:47 -0600 |
---|---|---|
committer | Nilay Vaish <nilay@cs.wisc.edu> | 2012-11-16 10:27:47 -0600 |
commit | 2d6470936ca06310b213117159fa0010259708cd (patch) | |
tree | 24fc62d3c1b27711fecadffacc722bbae45c3df9 /src/sim/eventq.hh | |
parent | 2680c827bee835175d780b82b93590e2b3467591 (diff) | |
download | gem5-2d6470936ca06310b213117159fa0010259708cd.tar.xz |
sim: have a curTick per eventq
This patch adds a _curTick variable to an eventq. This variable is updated
whenever an event is serviced in function serviceOne(), or all events upto
a particular time are processed in function serviceEvents(). This change
helps when there are eventqs that do not make use of curTick for scheduling
events.
Diffstat (limited to 'src/sim/eventq.hh')
-rw-r--r-- | src/sim/eventq.hh | 69 |
1 files changed, 8 insertions, 61 deletions
diff --git a/src/sim/eventq.hh b/src/sim/eventq.hh index 5362dcf34..5d5764a6a 100644 --- a/src/sim/eventq.hh +++ b/src/sim/eventq.hh @@ -44,7 +44,6 @@ #include "base/flags.hh" #include "base/misc.hh" -#include "base/trace.hh" #include "base/types.hh" #include "debug/Event.hh" #include "sim/serialize.hh" @@ -361,6 +360,7 @@ class EventQueue : public Serializable private: std::string objName; Event *head; + Tick _curTick; void insert(Event *event); void remove(Event *event); @@ -379,6 +379,9 @@ class EventQueue : public Serializable void reschedule(Event *event, Tick when, bool always = false); Tick nextTick() const { return head->when(); } + void setCurTick(Tick newVal) { _curTick = newVal; } + Tick getCurTick() { return _curTick; } + Event *serviceOne(); // process all events up to the given timestamp. we inline a @@ -398,6 +401,8 @@ class EventQueue : public Serializable //assert(head->when() >= when && "event scheduled in the past"); serviceOne(); } + + setCurTick(when); } // return true if no events are queued @@ -476,67 +481,9 @@ class EventManager { eventq->reschedule(event, when, always); } -}; - -inline void -EventQueue::schedule(Event *event, Tick when) -{ - assert(when >= curTick()); - assert(!event->scheduled()); - assert(event->initialized()); - - event->setWhen(when, this); - insert(event); - event->flags.set(Event::Scheduled); - if (this == &mainEventQueue) - event->flags.set(Event::IsMainQueue); - else - event->flags.clear(Event::IsMainQueue); - - if (DTRACE(Event)) - event->trace("scheduled"); -} - -inline void -EventQueue::deschedule(Event *event) -{ - assert(event->scheduled()); - assert(event->initialized()); - remove(event); - - event->flags.clear(Event::Squashed); - event->flags.clear(Event::Scheduled); - - if (DTRACE(Event)) - event->trace("descheduled"); - - if (event->flags.isSet(Event::AutoDelete)) - delete event; -} - -inline void -EventQueue::reschedule(Event *event, Tick when, bool always) -{ - assert(when >= curTick()); - assert(always || event->scheduled()); - assert(event->initialized()); - - if (event->scheduled()) - remove(event); - - event->setWhen(when, this); - insert(event); - event->flags.clear(Event::Squashed); - event->flags.set(Event::Scheduled); - if (this == &mainEventQueue) - event->flags.set(Event::IsMainQueue); - else - event->flags.clear(Event::IsMainQueue); - - if (DTRACE(Event)) - event->trace("rescheduled"); -} + void setCurTick(Tick newVal) { eventq->setCurTick(newVal); } +}; template <class T, void (T::* F)()> void |