- Switch events to use a priority enum instead of integers.

This lets us centralize priorities so we can see what's going on.
- Shift serialize & cpu-switch events to happen before CPU ticks (to be
consistent with starting new CPU on same cycle instead of next cycle).
- Get rid of unnecessary bus stats reset callback.

cpu/simple_cpu/simple_cpu.cc:
sim/debug.cc:
sim/eventq.hh:
sim/serialize.cc:
sim/sim_events.cc:
sim/sim_events.hh:
    Switch events to use a priority enum instead of integers.
    This lets us centralize priorities so we can see what's going on.

--HG--
extra : convert_revision : 510d79b43c0a1c97a10eb65916f7335b1de8b956
This commit is contained in:
Steve Reinhardt 2003-12-11 08:29:52 -08:00
parent 777c1ebfab
commit 7c708c8d1b
6 changed files with 56 additions and 35 deletions

View file

@ -75,7 +75,7 @@
using namespace std; using namespace std;
SimpleCPU::TickEvent::TickEvent(SimpleCPU *c) SimpleCPU::TickEvent::TickEvent(SimpleCPU *c)
: Event(&mainEventQueue, 100), cpu(c) : Event(&mainEventQueue, CPU_Tick_Pri), cpu(c)
{ {
} }

View file

@ -64,10 +64,10 @@ class DebugBreakEvent : public Event
// constructor: schedule at specified time // constructor: schedule at specified time
// //
DebugBreakEvent::DebugBreakEvent(EventQueue *q, Tick _when) DebugBreakEvent::DebugBreakEvent(EventQueue *q, Tick _when)
: Event(q) : Event(q, Debug_Break_Pri)
{ {
setFlags(AutoDelete); setFlags(AutoDelete);
schedule(_when, -20000); schedule(_when);
} }
// //

View file

@ -97,11 +97,52 @@ class Event : public Serializable, public FastAlloc
public: public:
/// Event priorities, to provide tie-breakers for events scheduled
/// at the same cycle. Most events are scheduled at the default
/// priority; these values are used to control events that need to
/// be ordered within a cycle.
enum Priority {
/// Breakpoints should happen before anything else, so we
/// don't miss any action when debugging.
Debug_Break_Pri = -100,
/// For some reason "delayed" inter-cluster writebacks are
/// scheduled before regular writebacks (which have default
/// priority). Steve?
Delayed_Writeback_Pri = -1,
/// Default is zero for historical reasons.
Default_Pri = 0,
/// CPU switches schedule the new CPU's tick event for the
/// same cycle (after unscheduling the old CPU's tick event).
/// The switch needs to come before any tick events to make
/// sure we don't tick both CPUs in the same cycle.
CPU_Switch_Pri = 31,
/// Serailization needs to occur before tick events also, so
/// that a serialize/unserialize is identical to an on-line
/// CPU switch.
Serialize_Pri = 32,
/// CPU ticks must come after other associated CPU events
/// (such as writebacks).
CPU_Tick_Pri = 50,
/// Statistics events (dump, reset, etc.) come after
/// everything else, but before exit.
Stat_Event_Pri = 90,
/// If we want to exit on this cycle, it's the very last thing
/// we do.
Sim_Exit_Pri = 100
};
/* /*
* Event constructor * Event constructor
* @param queue that the event gets scheduled on * @param queue that the event gets scheduled on
*/ */
Event(EventQueue *q, int p = 0) Event(EventQueue *q, Priority p = Default_Pri)
: queue(q), next(NULL), _priority(p), _flags(None), : queue(q), next(NULL), _priority(p), _flags(None),
#if TRACING_ON #if TRACING_ON
when_created(curTick), when_scheduled(0), when_created(curTick), when_scheduled(0),
@ -122,15 +163,9 @@ class Event : public Serializable, public FastAlloc
/// Schedule the event with the current priority or default priority /// Schedule the event with the current priority or default priority
void schedule(Tick t); void schedule(Tick t);
/// Schedule the event with a specific priority
void schedule(Tick t, int priority);
/// Reschedule the event with the current priority /// Reschedule the event with the current priority
void reschedule(Tick t); void reschedule(Tick t);
/// Reschedule the event with a specific priority
void reschedule(Tick t, int priority);
/// Remove the event from the current schedule /// Remove the event from the current schedule
void deschedule(); void deschedule();
@ -283,13 +318,6 @@ Event::schedule(Tick t)
queue->schedule(this); queue->schedule(this);
} }
inline void
Event::schedule(Tick t, int p)
{
_priority = p;
schedule(t);
}
inline void inline void
Event::deschedule() Event::deschedule()
{ {
@ -313,13 +341,6 @@ Event::reschedule(Tick t)
queue->reschedule(this); queue->reschedule(this);
} }
inline void
Event::reschedule(Tick t, int p)
{
_priority = p;
reschedule(t);
}
inline void inline void
EventQueue::schedule(Event *event) EventQueue::schedule(Event *event)
{ {

View file

@ -259,7 +259,7 @@ class SerializeEvent : public Event
}; };
SerializeEvent::SerializeEvent(Tick _when, Tick _repeat) SerializeEvent::SerializeEvent(Tick _when, Tick _repeat)
: Event(&mainEventQueue, 990), repeat(_repeat) : Event(&mainEventQueue, Serialize_Pri), repeat(_repeat)
{ {
setFlags(AutoDelete); setFlags(AutoDelete);
schedule(_when); schedule(_when);

View file

@ -68,14 +68,14 @@ SimExitEvent::description()
// //
CountedExitEvent::CountedExitEvent(EventQueue *q, const std::string &_cause, CountedExitEvent::CountedExitEvent(EventQueue *q, const std::string &_cause,
Tick _when, int &_downCounter) Tick _when, int &_downCounter)
: Event(q), : Event(q, Sim_Exit_Pri),
cause(_cause), cause(_cause),
downCounter(_downCounter) downCounter(_downCounter)
{ {
// catch stupid mistakes // catch stupid mistakes
assert(downCounter > 0); assert(downCounter > 0);
schedule(_when, 1000); schedule(_when);
} }

View file

@ -43,23 +43,23 @@ class SimExitEvent : public Event
public: public:
SimExitEvent(const std::string &_cause, int c = 0) SimExitEvent(const std::string &_cause, int c = 0)
: Event(&mainEventQueue), cause(_cause), : Event(&mainEventQueue, Sim_Exit_Pri), cause(_cause),
code(c) code(c)
{ schedule(curTick, 1000); } { schedule(curTick); }
SimExitEvent(Tick _when, const std::string &_cause, int c = 0) SimExitEvent(Tick _when, const std::string &_cause, int c = 0)
: Event(&mainEventQueue), cause(_cause), : Event(&mainEventQueue, Sim_Exit_Pri), cause(_cause),
code(c) code(c)
{ schedule(_when, 1000); } { schedule(_when); }
SimExitEvent(EventQueue *q, const std::string &_cause, int c = 0) SimExitEvent(EventQueue *q, const std::string &_cause, int c = 0)
: Event(q), cause(_cause), code(c) : Event(q, Sim_Exit_Pri), cause(_cause), code(c)
{ schedule(curTick, 1000); } { schedule(curTick); }
SimExitEvent(EventQueue *q, Tick _when, const std::string &_cause, SimExitEvent(EventQueue *q, Tick _when, const std::string &_cause,
int c = 0) int c = 0)
: Event(q), cause(_cause), code(c) : Event(q, Sim_Exit_Pri), cause(_cause), code(c)
{ schedule(_when, 1000); } { schedule(_when); }
void process(); // process event void process(); // process event