From: Tushar Krishna Date: Mon, 22 Mar 2010 04:22:21 +0000 (-0700) Subject: ruby: Fix multiple wakeups in Ruby Eventqueue X-Git-Tag: stable_2012_02_02~1461 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7c20d5511a7c22b360529f2f8452b7d4d5a9785d;p=gem5.git ruby: Fix multiple wakeups in Ruby Eventqueue Fix bug in Ruby Event queue to avoid multiple wakeups of same consumer in same cycle --- diff --git a/src/mem/ruby/common/Consumer.hh b/src/mem/ruby/common/Consumer.hh index 955c1ffa9..e541ef615 100644 --- a/src/mem/ruby/common/Consumer.hh +++ b/src/mem/ruby/common/Consumer.hh @@ -40,6 +40,7 @@ #define CONSUMER_H #include +#include #include "mem/ruby/common/Global.hh" #include "mem/ruby/eventqueue/RubyEventQueue.hh" @@ -55,18 +56,43 @@ public: virtual ~Consumer() { } // Public Methods - pure virtual methods - // void triggerWakeup() { Time time = g_eventQueue_ptr->getTime(); if (m_last_wakeup != time) { wakeup(); m_last_wakeup = time; }} - void triggerWakeup(RubyEventQueue * eventQueue) { Time time = eventQueue->getTime(); if (m_last_wakeup != time) { wakeup(); m_last_wakeup = time; }} + void triggerWakeup(RubyEventQueue * eventQueue) + { + Time time = eventQueue->getTime(); + if (m_last_wakeup != time) { + wakeup(); m_last_wakeup = time; + } + } virtual void wakeup() = 0; virtual void print(std::ostream& out) const = 0; - const Time& getLastScheduledWakeup() const { return m_last_scheduled_wakeup; } - void setLastScheduledWakeup(const Time& time) { m_last_scheduled_wakeup = time; } + const Time& getLastScheduledWakeup() const + { + return m_last_scheduled_wakeup; + } + void setLastScheduledWakeup(const Time& time) + { + m_last_scheduled_wakeup = time; + } + bool alreadyScheduled(Time time) + { + return (m_scheduled_wakeups.find(time) != m_scheduled_wakeups.end()); + } + void insertScheduledWakeupTime(Time time) + { + m_scheduled_wakeups.insert(time); + } + void removeScheduledWakeupTime(Time time) + { + assert(alreadyScheduled(time)); + m_scheduled_wakeups.erase(time); + } private: // Private Methods // Data Members (m_ prefix) Time m_last_scheduled_wakeup; + std::set