From 86b1c0fd540b57c1e7bba948ad0417f22f90eb41 Mon Sep 17 00:00:00 2001 From: Nilay Vaish Date: Tue, 18 Sep 2012 22:46:34 -0500 Subject: ruby: avoid using g_system_ptr for event scheduling This patch removes the use of g_system_ptr for event scheduling. Each consumer object now needs to specify upfront an EventManager object it would use for scheduling events. This makes the ruby memory system more amenable for a multi-threaded simulation. --- src/mem/ruby/common/Consumer.cc | 14 +------------- src/mem/ruby/common/Consumer.hh | 7 +++---- 2 files changed, 4 insertions(+), 17 deletions(-) (limited to 'src/mem/ruby/common') diff --git a/src/mem/ruby/common/Consumer.cc b/src/mem/ruby/common/Consumer.cc index 1f7aeebd5..de6a8f448 100644 --- a/src/mem/ruby/common/Consumer.cc +++ b/src/mem/ruby/common/Consumer.cc @@ -33,23 +33,11 @@ void Consumer::scheduleEvent(Time timeDelta) { - scheduleEvent(g_system_ptr, timeDelta); -} - -void -Consumer::scheduleEvent(EventManager *em, Time timeDelta) -{ - scheduleEventAbsolute(em, timeDelta + g_system_ptr->getTime()); + scheduleEventAbsolute(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 = g_system_ptr->clockPeriod() * timeAbs; if (!alreadyScheduled(evt_time)) { diff --git a/src/mem/ruby/common/Consumer.hh b/src/mem/ruby/common/Consumer.hh index 6a67bde39..a10abf362 100644 --- a/src/mem/ruby/common/Consumer.hh +++ b/src/mem/ruby/common/Consumer.hh @@ -44,8 +44,8 @@ class Consumer { public: - Consumer() - : m_last_scheduled_wakeup(0), m_last_wakeup(0) + Consumer(EventManager *_em) + : m_last_scheduled_wakeup(0), m_last_wakeup(0), em(_em) { } @@ -88,8 +88,6 @@ class Consumer 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); @@ -97,6 +95,7 @@ class Consumer Tick m_last_scheduled_wakeup; std::set m_scheduled_wakeups; Tick m_last_wakeup; + EventManager *em; class ConsumerEvent : public Event { -- cgit v1.2.3