From 7c20d5511a7c22b360529f2f8452b7d4d5a9785d Mon Sep 17 00:00:00 2001 From: Tushar Krishna Date: Sun, 21 Mar 2010 21:22:21 -0700 Subject: [PATCH] ruby: Fix multiple wakeups in Ruby Eventqueue Fix bug in Ruby Event queue to avoid multiple wakeups of same consumer in same cycle --- src/mem/ruby/common/Consumer.hh | 34 ++++++++++++++++--- src/mem/ruby/eventqueue/RubyEventQueue.cc | 6 ++-- src/mem/ruby/eventqueue/RubyEventQueueNode.hh | 11 ++++-- 3 files changed, 41 insertions(+), 10 deletions(-) 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