summaryrefslogtreecommitdiff
path: root/src/mem/ruby/common
diff options
context:
space:
mode:
authorNilay Vaish <nilay@cs.wisc.edu>2012-08-27 01:00:55 -0500
committerNilay Vaish <nilay@cs.wisc.edu>2012-08-27 01:00:55 -0500
commit9190940511b5783811bc6288dd4f22f8d18c9d26 (patch)
tree72a07f80a772d7c6f2a6f0255cee173ac631cb35 /src/mem/ruby/common
parent7122b83d8f92d77bccae432b4e90ba12f1babad5 (diff)
downloadgem5-9190940511b5783811bc6288dd4f22f8d18c9d26.tar.xz
Ruby: Remove RubyEventQueue
This patch removes RubyEventQueue. Consumer objects now rely on RubySystem or themselves for scheduling events.
Diffstat (limited to 'src/mem/ruby/common')
-rw-r--r--src/mem/ruby/common/Consumer.cc63
-rw-r--r--src/mem/ruby/common/Consumer.hh55
-rw-r--r--src/mem/ruby/common/Global.cc2
-rw-r--r--src/mem/ruby/common/Global.hh3
-rw-r--r--src/mem/ruby/common/SConscript1
-rw-r--r--src/mem/ruby/common/TypeDefines.hh2
6 files changed, 97 insertions, 29 deletions
diff --git a/src/mem/ruby/common/Consumer.cc b/src/mem/ruby/common/Consumer.cc
new file mode 100644
index 000000000..a81396217
--- /dev/null
+++ b/src/mem/ruby/common/Consumer.cc
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2012 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "mem/ruby/common/Consumer.hh"
+#include "mem/ruby/common/Global.hh"
+#include "mem/ruby/system/System.hh"
+
+void
+Consumer::scheduleEvent(Time timeDelta)
+{
+ scheduleEvent(g_system_ptr, timeDelta);
+}
+
+void
+Consumer::scheduleEvent(EventManager *em, Time timeDelta)
+{
+ scheduleEventAbsolute(em, timeDelta + g_system_ptr->getTime());
+}
+
+void
+Consumer::scheduleEventAbsolute(Time timeAbs)
+{
+ scheduleEventAbsolute(g_system_ptr, timeAbs);
+}
+
+void
+Consumer::scheduleEventAbsolute(EventManager *em, Time timeAbs)
+{
+ Tick evt_time = timeAbs * g_system_ptr->getClock();
+ if (!alreadyScheduled(evt_time)) {
+ // This wakeup is not redundant
+ ConsumerEvent *evt = new ConsumerEvent(this);
+ assert(timeAbs > g_system_ptr->getTime());
+
+ em->schedule(evt, evt_time);
+ insertScheduledWakeupTime(evt_time);
+ }
+}
diff --git a/src/mem/ruby/common/Consumer.hh b/src/mem/ruby/common/Consumer.hh
index a119abb39..6a67bde39 100644
--- a/src/mem/ruby/common/Consumer.hh
+++ b/src/mem/ruby/common/Consumer.hh
@@ -38,10 +38,8 @@
#include <iostream>
#include <set>
-#include "mem/ruby/common/Global.hh"
-#include "mem/ruby/eventqueue/RubyEventQueue.hh"
-
-class MessageBuffer;
+#include "mem/ruby/common/TypeDefines.hh"
+#include "sim/eventq.hh"
class Consumer
{
@@ -55,55 +53,68 @@ class Consumer
~Consumer()
{ }
- 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;
virtual void storeEventInfo(int info) {}
- const Time&
+ const Tick&
getLastScheduledWakeup() const
{
return m_last_scheduled_wakeup;
}
void
- setLastScheduledWakeup(const Time& time)
+ setLastScheduledWakeup(const Tick& time)
{
m_last_scheduled_wakeup = time;
}
bool
- alreadyScheduled(Time time)
+ alreadyScheduled(Tick time)
{
return m_scheduled_wakeups.find(time) != m_scheduled_wakeups.end();
}
void
- insertScheduledWakeupTime(Time time)
+ insertScheduledWakeupTime(Tick time)
{
m_scheduled_wakeups.insert(time);
}
void
- removeScheduledWakeupTime(Time time)
+ removeScheduledWakeupTime(Tick time)
{
assert(alreadyScheduled(time));
m_scheduled_wakeups.erase(time);
}
+ void scheduleEvent(EventManager* em, Time timeDelta);
+ void scheduleEventAbsolute(EventManager* em, Time timeAbs);
+ void scheduleEvent(Time timeDelta);
+ void scheduleEventAbsolute(Time timeAbs);
+
private:
- Time m_last_scheduled_wakeup;
- std::set<Time> m_scheduled_wakeups;
- Time m_last_wakeup;
+ Tick m_last_scheduled_wakeup;
+ std::set<Tick> m_scheduled_wakeups;
+ Tick m_last_wakeup;
+
+ class ConsumerEvent : public Event
+ {
+ public:
+ ConsumerEvent(Consumer* _consumer)
+ : Event(Default_Pri, AutoDelete), m_consumer_ptr(_consumer)
+ {
+ }
+
+ void process()
+ {
+ m_consumer_ptr->wakeup();
+ m_consumer_ptr->removeScheduledWakeupTime(when());
+ }
+
+ private:
+ Consumer* m_consumer_ptr;
+ };
};
inline std::ostream&
diff --git a/src/mem/ruby/common/Global.cc b/src/mem/ruby/common/Global.cc
index e771de7ae..a2ed4e6ae 100644
--- a/src/mem/ruby/common/Global.cc
+++ b/src/mem/ruby/common/Global.cc
@@ -28,6 +28,4 @@
#include "mem/ruby/common/Global.hh"
-RubyEventQueue* g_eventQueue_ptr = 0;
RubySystem* g_system_ptr = 0;
-
diff --git a/src/mem/ruby/common/Global.hh b/src/mem/ruby/common/Global.hh
index cae7cb16b..f76a1a26b 100644
--- a/src/mem/ruby/common/Global.hh
+++ b/src/mem/ruby/common/Global.hh
@@ -31,9 +31,6 @@
#include "base/str.hh"
-class RubyEventQueue;
-extern RubyEventQueue* g_eventQueue_ptr;
-
class RubySystem;
extern RubySystem* g_system_ptr;
diff --git a/src/mem/ruby/common/SConscript b/src/mem/ruby/common/SConscript
index aab35a09c..c7e774b47 100644
--- a/src/mem/ruby/common/SConscript
+++ b/src/mem/ruby/common/SConscript
@@ -34,6 +34,7 @@ if env['PROTOCOL'] == 'None':
Return()
Source('Address.cc')
+Source('Consumer.cc')
Source('DataBlock.cc')
Source('Global.cc')
Source('Histogram.cc')
diff --git a/src/mem/ruby/common/TypeDefines.hh b/src/mem/ruby/common/TypeDefines.hh
index 233c9146a..a7b8a6101 100644
--- a/src/mem/ruby/common/TypeDefines.hh
+++ b/src/mem/ruby/common/TypeDefines.hh
@@ -35,8 +35,6 @@ typedef unsigned char uint8;
typedef unsigned int uint32;
typedef unsigned long long uint64;
-typedef signed char int8;
-typedef int int32;
typedef long long int64;
typedef long long integer_t;