From 564482c78283c749dc537cb9c1b2d788bf306a82 Mon Sep 17 00:00:00 2001 From: Curtis Dunham Date: Mon, 23 Mar 2015 06:57:36 -0400 Subject: sim: Reuse the same limit_event in simulate() This patch accomplishes two things: 1. Makes simulate()'s GlobalSimLoopExitEvent a singleton reused across calls. This is slightly more efficient than recreating it every time. 2. Gives callers to simulate() (especially other simulators) a foolproof way of knowing that the simulation period ended successfully by hitting the limit event. They can call getLimitEvent() and compare it to the return value of simulate(). This change was motivated by an ongoing effort to integrate gem5 and SST, with SST as the master sim and gem5 as the slave sim. --- src/sim/sim_events.hh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/sim/sim_events.hh') diff --git a/src/sim/sim_events.hh b/src/sim/sim_events.hh index 5be2609fd..4d001f8f0 100644 --- a/src/sim/sim_events.hh +++ b/src/sim/sim_events.hh @@ -71,6 +71,11 @@ class GlobalSimLoopExitEvent : public GlobalEvent void process(); // process event virtual const char *description() const; + + virtual ~GlobalSimLoopExitEvent() { + // simulate()'s singleton GlobalSimLoopExitEvent is always scheduled + deschedule(); + } }; class LocalSimLoopExitEvent : public Event -- cgit v1.2.3