summaryrefslogtreecommitdiff
path: root/src/sim/sim_events.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/sim/sim_events.cc')
-rw-r--r--src/sim/sim_events.cc39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/sim/sim_events.cc b/src/sim/sim_events.cc
index 2aa0508ef..b7901832d 100644
--- a/src/sim/sim_events.cc
+++ b/src/sim/sim_events.cc
@@ -45,26 +45,37 @@ using namespace std;
// handle termination event
//
void
-SimExitEvent::process()
+SimLoopExitEvent::process()
{
- // This event does not autodelete because exitNow may be called,
- // and the function will never be allowed to finish.
- if (theQueue() == &mainEventQueue) {
- string _cause = cause;
- int _code = code;
- delete this;
- exitNow(_cause, _code);
- } else {
- new SimExitEvent(cause, code);
+ // 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) {
+ exitSimLoop(cause, code);
delete this;
}
+
+ // otherwise do nothing... the IsExitEvent flag takes care of
+ // exiting the simulation loop and returning this object to Python
}
const char *
-SimExitEvent::description()
+SimLoopExitEvent::description()
+{
+ return "simulation loop exit";
+}
+
+void
+exitSimLoop(Tick when, const std::string &message, int exit_code)
+{
+ new SimLoopExitEvent(when, message, exit_code);
+}
+
+void
+exitSimLoop(const std::string &message, int exit_code)
{
- return "simulation termination";
+ exitSimLoop(curTick, message, exit_code);
}
//
@@ -90,7 +101,7 @@ void
CountedExitEvent::process()
{
if (--downCounter == 0) {
- new SimExitEvent(cause, 0);
+ exitSimLoop(cause, 0);
}
}
@@ -119,7 +130,7 @@ CheckSwapEvent::process()
if (swap < 100) {
cerr << "\a\aAborting Simulation! Inadequate swap space!\n\n";
- new SimExitEvent("Lack of swap space");
+ exitSimLoop("Lack of swap space");
}
schedule(curTick + interval);