ruby: consumer: avoid accessing wakeup times when waking up
Each consumer object maintains a set of tick values when the object is supposed to wakeup and do some processing. As of now, the object accesses this set both when scheduling a wakeup event and when the object actually wakes up. The set is accessed during wakeup to remove the current tick value from the set. This functionality is now being moved to the scheduling function where ticks are removed at a later time.
This commit is contained in:
parent
4b67ada89e
commit
52a83c1d0e
2 changed files with 9 additions and 26 deletions
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include "mem/ruby/common/Consumer.hh"
|
#include "mem/ruby/common/Consumer.hh"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
void
|
void
|
||||||
Consumer::scheduleEvent(Cycles timeDelta)
|
Consumer::scheduleEvent(Cycles timeDelta)
|
||||||
{
|
{
|
||||||
|
@ -43,4 +45,9 @@ Consumer::scheduleEventAbsolute(Tick evt_time)
|
||||||
em->schedule(evt, evt_time);
|
em->schedule(evt, evt_time);
|
||||||
insertScheduledWakeupTime(evt_time);
|
insertScheduledWakeupTime(evt_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tick t = em->clockEdge();
|
||||||
|
set<Tick>::iterator bit = m_scheduled_wakeups.begin();
|
||||||
|
set<Tick>::iterator eit = m_scheduled_wakeups.lower_bound(t);
|
||||||
|
m_scheduled_wakeups.erase(bit,eit);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ class Consumer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Consumer(ClockedObject *_em)
|
Consumer(ClockedObject *_em)
|
||||||
: m_last_scheduled_wakeup(0), em(_em)
|
: em(_em)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,18 +56,6 @@ class Consumer
|
||||||
virtual void print(std::ostream& out) const = 0;
|
virtual void print(std::ostream& out) const = 0;
|
||||||
virtual void storeEventInfo(int info) {}
|
virtual void storeEventInfo(int info) {}
|
||||||
|
|
||||||
const Tick&
|
|
||||||
getLastScheduledWakeup() const
|
|
||||||
{
|
|
||||||
return m_last_scheduled_wakeup;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
setLastScheduledWakeup(const Tick& time)
|
|
||||||
{
|
|
||||||
m_last_scheduled_wakeup = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
alreadyScheduled(Tick time)
|
alreadyScheduled(Tick time)
|
||||||
{
|
{
|
||||||
|
@ -80,20 +68,12 @@ class Consumer
|
||||||
m_scheduled_wakeups.insert(time);
|
m_scheduled_wakeups.insert(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
removeScheduledWakeupTime(Tick time)
|
|
||||||
{
|
|
||||||
assert(alreadyScheduled(time));
|
|
||||||
m_scheduled_wakeups.erase(time);
|
|
||||||
}
|
|
||||||
|
|
||||||
void scheduleEventAbsolute(Tick timeAbs);
|
void scheduleEventAbsolute(Tick timeAbs);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void scheduleEvent(Cycles timeDelta);
|
void scheduleEvent(Cycles timeDelta);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Tick m_last_scheduled_wakeup;
|
|
||||||
std::set<Tick> m_scheduled_wakeups;
|
std::set<Tick> m_scheduled_wakeups;
|
||||||
ClockedObject *em;
|
ClockedObject *em;
|
||||||
|
|
||||||
|
@ -105,11 +85,7 @@ class Consumer
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void process()
|
void process() { m_consumer_ptr->wakeup(); }
|
||||||
{
|
|
||||||
m_consumer_ptr->wakeup();
|
|
||||||
m_consumer_ptr->removeScheduledWakeupTime(when());
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Consumer* m_consumer_ptr;
|
Consumer* m_consumer_ptr;
|
||||||
|
|
Loading…
Reference in a new issue