eventq: convert all usage of events to use the new API.

For now, there is still a single global event queue, but this is
necessary for making the steps towards a parallelized m5.
This commit is contained in:
Nathan Binkert
2008-10-09 04:58:24 -07:00
parent 8291d9db0a
commit e06321091d
68 changed files with 398 additions and 388 deletions

View File

@@ -47,7 +47,7 @@ Bridge::BridgePort::BridgePort(const std::string &_name,
int _delay, int _nack_delay, int _req_limit,
int _resp_limit,
std::vector<Range<Addr> > filter_ranges)
: Port(_name), bridge(_bridge), otherPort(_otherPort),
: Port(_name, _bridge), bridge(_bridge), otherPort(_otherPort),
delay(_delay), nackDelay(_nack_delay), filterRanges(filter_ranges),
outstandingResponses(0), queuedRequests(0), inRetry(false),
reqQueueLimit(_req_limit), respQueueLimit(_resp_limit), sendEvent(this)
@@ -162,7 +162,7 @@ Bridge::BridgePort::nackRequest(PacketPtr pkt)
// nothing on the list, add it and we're done
if (sendQueue.empty()) {
assert(!sendEvent.scheduled());
sendEvent.schedule(readyTime);
schedule(sendEvent, readyTime);
sendQueue.push_back(buf);
return;
}
@@ -184,7 +184,7 @@ Bridge::BridgePort::nackRequest(PacketPtr pkt)
while (i != end && !done) {
if (readyTime < (*i)->ready) {
if (i == begin)
sendEvent.reschedule(readyTime);
reschedule(sendEvent, readyTime);
sendQueue.insert(i,buf);
done = true;
}
@@ -227,7 +227,7 @@ Bridge::BridgePort::queueForSendTiming(PacketPtr pkt)
// should already be an event scheduled for sending the head
// packet.
if (sendQueue.empty()) {
sendEvent.schedule(readyTime);
schedule(sendEvent, readyTime);
}
sendQueue.push_back(buf);
}
@@ -281,7 +281,7 @@ Bridge::BridgePort::trySend()
if (!sendQueue.empty()) {
buf = sendQueue.front();
DPRINTF(BusBridge, "Scheduling next send\n");
sendEvent.schedule(std::max(buf->ready, curTick + 1));
schedule(sendEvent, std::max(buf->ready, curTick + 1));
}
} else {
DPRINTF(BusBridge, " unsuccessful\n");
@@ -302,7 +302,7 @@ Bridge::BridgePort::recvRetry()
if (nextReady <= curTick)
trySend();
else
sendEvent.schedule(nextReady);
schedule(sendEvent, nextReady);
}
/** Function called by the port when the bus is receiving a Atomic

View File

@@ -146,11 +146,8 @@ class Bridge : public MemObject
BridgePort *port;
public:
SendEvent(BridgePort *p)
: Event(&mainEventQueue), port(p) {}
SendEvent(BridgePort *p) : port(p) {}
virtual void process() { port->trySend(); }
virtual const char *description() const { return "bridge send"; }
};

View File

@@ -97,20 +97,24 @@ Bus::init()
intIter->second->sendStatusChange(Port::RangeChange);
}
Bus::BusFreeEvent::BusFreeEvent(Bus *_bus) : Event(&mainEventQueue), bus(_bus)
Bus::BusFreeEvent::BusFreeEvent(Bus *_bus)
: bus(_bus)
{}
void Bus::BusFreeEvent::process()
void
Bus::BusFreeEvent::process()
{
bus->recvRetry(-1);
}
const char * Bus::BusFreeEvent::description() const
const char *
Bus::BusFreeEvent::description() const
{
return "bus became available";
}
Tick Bus::calcPacketTiming(PacketPtr pkt)
Tick
Bus::calcPacketTiming(PacketPtr pkt)
{
// Bring tickNextIdle up to the present tick.
// There is some potential ambiguity where a cycle starts, which
@@ -155,12 +159,8 @@ void Bus::occupyBus(Tick until)
}
tickNextIdle = until;
reschedule(busIdle, tickNextIdle, true);
if (!busIdle.scheduled()) {
busIdle.schedule(tickNextIdle);
} else {
busIdle.reschedule(tickNextIdle);
}
DPRINTF(Bus, "The bus is now occupied from tick %d to %d\n",
curTick, tickNextIdle);
}
@@ -293,7 +293,7 @@ Bus::recvRetry(int id)
//Burn a cycle for the missed grant.
tickNextIdle += clock;
busIdle.reschedule(tickNextIdle, true);
reschedule(busIdle, tickNextIdle, true);
}
}
//If we weren't able to drain before, we might be able to now.

View File

@@ -122,7 +122,7 @@ BaseCache::CachePort::clearBlocked()
mustSendRetry = false;
SendRetryEvent *ev = new SendRetryEvent(this, true);
// @TODO: need to find a better time (next bus cycle?)
ev->schedule(curTick + 1);
schedule(ev, curTick + 1);
}
}

View File

@@ -1489,7 +1489,7 @@ Cache<TagStore>::MemSidePort::sendPacket()
// @TODO: need to facotr in prefetch requests here somehow
if (nextReady != MaxTick) {
DPRINTF(CachePort, "more packets to send @ %d\n", nextReady);
sendEvent->schedule(std::max(nextReady, curTick + 1));
schedule(sendEvent, std::max(nextReady, curTick + 1));
} else {
// no more to send right now: if we're draining, we may be done
if (drainEvent) {

View File

@@ -383,7 +383,7 @@ PhysicalMemory::recvStatusChange(Port::Status status)
PhysicalMemory::MemoryPort::MemoryPort(const std::string &_name,
PhysicalMemory *_memory)
: SimpleTimingPort(_name), memory(_memory)
: SimpleTimingPort(_name, _memory), memory(_memory)
{ }
void

View File

@@ -138,7 +138,7 @@ SimpleTimingPort::sendDeferredPacket()
if (success) {
if (!transmitList.empty() && !sendEvent->scheduled()) {
Tick time = transmitList.front().tick;
sendEvent->schedule(time <= curTick ? curTick+1 : time);
schedule(sendEvent, time <= curTick ? curTick+1 : time);
}
if (transmitList.empty() && drainEvent) {

View File

@@ -108,7 +108,8 @@ class SimpleTimingPort : public Port
Tick deferredPacketReadyTime()
{ return transmitList.empty() ? MaxTick : transmitList.front().tick; }
void schedSendEvent(Tick when)
void
schedSendEvent(Tick when)
{
if (waitingOnRetry) {
assert(!sendEvent->scheduled());
@@ -116,9 +117,9 @@ class SimpleTimingPort : public Port
}
if (!sendEvent->scheduled()) {
sendEvent->schedule(when);
schedule(sendEvent, when);
} else if (sendEvent->when() > when) {
sendEvent->reschedule(when);
reschedule(sendEvent, when);
}
}
@@ -155,7 +156,7 @@ class SimpleTimingPort : public Port
public:
SimpleTimingPort(std::string pname, MemObject *_owner = NULL)
SimpleTimingPort(std::string pname, MemObject *_owner)
: Port(pname, _owner),
sendEvent(new SendEvent(this)),
drainEvent(NULL),