From 7c708c8d1b9b251439227cfb49006f0b149cf197 Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Thu, 11 Dec 2003 08:29:52 -0800 Subject: - 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 --- cpu/simple_cpu/simple_cpu.cc | 2 +- sim/debug.cc | 4 +-- sim/eventq.hh | 63 +++++++++++++++++++++++++++++--------------- sim/serialize.cc | 2 +- sim/sim_events.cc | 4 +-- sim/sim_events.hh | 16 +++++------ 6 files changed, 56 insertions(+), 35 deletions(-) diff --git a/cpu/simple_cpu/simple_cpu.cc b/cpu/simple_cpu/simple_cpu.cc index 2bbfb82f1..adbd17a35 100644 --- a/cpu/simple_cpu/simple_cpu.cc +++ b/cpu/simple_cpu/simple_cpu.cc @@ -75,7 +75,7 @@ using namespace std; SimpleCPU::TickEvent::TickEvent(SimpleCPU *c) - : Event(&mainEventQueue, 100), cpu(c) + : Event(&mainEventQueue, CPU_Tick_Pri), cpu(c) { } diff --git a/sim/debug.cc b/sim/debug.cc index 6f3789c96..09c604a95 100644 --- a/sim/debug.cc +++ b/sim/debug.cc @@ -64,10 +64,10 @@ class DebugBreakEvent : public Event // constructor: schedule at specified time // DebugBreakEvent::DebugBreakEvent(EventQueue *q, Tick _when) - : Event(q) + : Event(q, Debug_Break_Pri) { setFlags(AutoDelete); - schedule(_when, -20000); + schedule(_when); } // diff --git a/sim/eventq.hh b/sim/eventq.hh index dc1b2d9af..36cb402a8 100644 --- a/sim/eventq.hh +++ b/sim/eventq.hh @@ -97,11 +97,52 @@ class Event : public Serializable, public FastAlloc 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 * @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), #if TRACING_ON 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 void schedule(Tick t); - /// Schedule the event with a specific priority - void schedule(Tick t, int priority); - /// Reschedule the event with the current priority void reschedule(Tick t); - /// Reschedule the event with a specific priority - void reschedule(Tick t, int priority); - /// Remove the event from the current schedule void deschedule(); @@ -283,13 +318,6 @@ Event::schedule(Tick t) queue->schedule(this); } -inline void -Event::schedule(Tick t, int p) -{ - _priority = p; - schedule(t); -} - inline void Event::deschedule() { @@ -313,13 +341,6 @@ Event::reschedule(Tick t) queue->reschedule(this); } -inline void -Event::reschedule(Tick t, int p) -{ - _priority = p; - reschedule(t); -} - inline void EventQueue::schedule(Event *event) { diff --git a/sim/serialize.cc b/sim/serialize.cc index 82d295384..95aacc361 100644 --- a/sim/serialize.cc +++ b/sim/serialize.cc @@ -259,7 +259,7 @@ class SerializeEvent : public Event }; SerializeEvent::SerializeEvent(Tick _when, Tick _repeat) - : Event(&mainEventQueue, 990), repeat(_repeat) + : Event(&mainEventQueue, Serialize_Pri), repeat(_repeat) { setFlags(AutoDelete); schedule(_when); diff --git a/sim/sim_events.cc b/sim/sim_events.cc index 7456e788b..a31da18dd 100644 --- a/sim/sim_events.cc +++ b/sim/sim_events.cc @@ -68,14 +68,14 @@ SimExitEvent::description() // CountedExitEvent::CountedExitEvent(EventQueue *q, const std::string &_cause, Tick _when, int &_downCounter) - : Event(q), + : Event(q, Sim_Exit_Pri), cause(_cause), downCounter(_downCounter) { // catch stupid mistakes assert(downCounter > 0); - schedule(_when, 1000); + schedule(_when); } diff --git a/sim/sim_events.hh b/sim/sim_events.hh index c4db248e0..4a8e7c115 100644 --- a/sim/sim_events.hh +++ b/sim/sim_events.hh @@ -43,23 +43,23 @@ class SimExitEvent : public Event public: SimExitEvent(const std::string &_cause, int c = 0) - : Event(&mainEventQueue), cause(_cause), + : Event(&mainEventQueue, Sim_Exit_Pri), cause(_cause), code(c) - { schedule(curTick, 1000); } + { schedule(curTick); } SimExitEvent(Tick _when, const std::string &_cause, int c = 0) - : Event(&mainEventQueue), cause(_cause), + : Event(&mainEventQueue, Sim_Exit_Pri), cause(_cause), code(c) - { schedule(_when, 1000); } + { schedule(_when); } SimExitEvent(EventQueue *q, const std::string &_cause, int c = 0) - : Event(q), cause(_cause), code(c) - { schedule(curTick, 1000); } + : Event(q, Sim_Exit_Pri), cause(_cause), code(c) + { schedule(curTick); } SimExitEvent(EventQueue *q, Tick _when, const std::string &_cause, int c = 0) - : Event(q), cause(_cause), code(c) - { schedule(_when, 1000); } + : Event(q, Sim_Exit_Pri), cause(_cause), code(c) + { schedule(_when); } void process(); // process event -- cgit v1.2.3