X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fsim%2Fsim_events.cc;h=725e7da9deb61fcd992de67b513f9cf71f6157b8;hb=0737837109570758f86a40d11d14886a0e4965ef;hp=09087ef8428b7df46f55a3cee6708c0cf941ceb6;hpb=71835d42df8fb488380be8cc89be4298b268902a;p=gem5.git diff --git a/src/sim/sim_events.cc b/src/sim/sim_events.cc index 09087ef84..725e7da9d 100644 --- a/src/sim/sim_events.cc +++ b/src/sim/sim_events.cc @@ -35,11 +35,16 @@ #include "sim/eventq.hh" #include "sim/sim_events.hh" #include "sim/sim_exit.hh" -#include "sim/startup.hh" #include "sim/stats.hh" using namespace std; +SimLoopExitEvent::SimLoopExitEvent(const std::string &_cause, int c, Tick r) + : Event(Sim_Exit_Pri, IsExitEvent), cause(_cause), code(c), repeat(r) +{ +} + + // // handle termination event // @@ -49,7 +54,7 @@ SimLoopExitEvent::process() // if this got scheduled on a different queue (e.g. the committed // instruction queue) then make a corresponding event on the main // queue. - if (theQueue() != &mainEventQueue) { + if (!isFlagSet(IsMainQueue)) { exitSimLoop(cause, code); delete this; } @@ -59,7 +64,8 @@ SimLoopExitEvent::process() // but if you are doing this on intervals, don't forget to make another if (repeat) { - schedule(curTick + repeat); + assert(isFlagSet(IsMainQueue)); + mainEventQueue.schedule(this, curTick() + repeat); } } @@ -70,43 +76,32 @@ SimLoopExitEvent::description() const return "simulation loop exit"; } -SimLoopExitEvent * -schedExitSimLoop(const std::string &message, Tick when, Tick repeat, - EventQueue *q, int exit_code) -{ - if (q == NULL) - q = &mainEventQueue; - - return new SimLoopExitEvent(q, when, repeat, message, exit_code); -} - void -exitSimLoop(const std::string &message, int exit_code) +exitSimLoop(const std::string &message, int exit_code, Tick when, Tick repeat) { - schedExitSimLoop(message, curTick, 0, NULL, exit_code); + Event *event = new SimLoopExitEvent(message, exit_code, repeat); + mainEventQueue.schedule(event, when); } +CountedDrainEvent::CountedDrainEvent() + : count(0) +{ } + void CountedDrainEvent::process() { - if (--count == 0) { - exitSimLoop("Finished drain"); - } + if (--count == 0) + exitSimLoop("Finished drain", 0); } // // constructor: automatically schedules at specified time // -CountedExitEvent::CountedExitEvent(EventQueue *q, const std::string &_cause, - Tick _when, int &_downCounter) - : Event(q, Sim_Exit_Pri), - cause(_cause), - downCounter(_downCounter) +CountedExitEvent::CountedExitEvent(const std::string &_cause, int &counter) + : Event(Sim_Exit_Pri), cause(_cause), downCounter(counter) { // catch stupid mistakes assert(downCounter > 0); - - schedule(_when); } @@ -127,33 +122,3 @@ CountedExitEvent::description() const { return "counted exit"; } - -#ifdef CHECK_SWAP_CYCLES -new CheckSwapEvent(&mainEventQueue, CHECK_SWAP_CYCLES); -#endif - -void -CheckSwapEvent::process() -{ - /* Check the amount of free swap space */ - long swap; - - /* returns free swap in KBytes */ - swap = procInfo("/proc/meminfo", "SwapFree:"); - - if (swap < 1000) - ccprintf(cerr, "\a\a\aWarning! Swap space is low (%d)\n", swap); - - if (swap < 100) { - cerr << "\a\aAborting Simulation! Inadequate swap space!\n\n"; - exitSimLoop("Lack of swap space"); - } - - schedule(curTick + interval); -} - -const char * -CheckSwapEvent::description() const -{ - return "check swap"; -}