Make the progress event work even after restoring from a checkpoint
authorNathan Binkert <binkertn@umich.edu>
Sun, 29 Feb 2004 23:49:44 +0000 (18:49 -0500)
committerNathan Binkert <binkertn@umich.edu>
Sun, 29 Feb 2004 23:49:44 +0000 (18:49 -0500)
--HG--
extra : convert_revision : 80e31eb26250700ebe3ce5848e570068cc76ef47

sim/sim_events.cc

index a31da18ddfc5b9ac96fdcc2a31ac887a7e45f333..f7b07359c0598079dc918ddc194979e89bdad274 100644 (file)
 
 #include <string>
 
-#include "sim/param.hh"
-#include "sim/eventq.hh"
+#include "base/callback.hh"
 #include "base/hostinfo.hh"
+#include "sim/eventq.hh"
+#include "sim/param.hh"
 #include "sim/sim_events.hh"
 #include "sim/sim_exit.hh"
+#include "sim/sim_init.hh"
 #include "sim/sim_stats.hh"
 
 using namespace std;
@@ -178,7 +180,7 @@ class ProgressEvent : public Event
 ProgressEvent::ProgressEvent(EventQueue *q, Tick _interval)
     : Event(q), interval(_interval)
 {
-    schedule(interval);
+    schedule(curTick + interval);
 }
 
 //
@@ -221,10 +223,24 @@ ProgressParamContext progessMessageParams("progress");
 Param<Tick> progress_interval(&progessMessageParams, "cycle",
                                 "cycle interval for progress messages");
 
+namespace {
+    struct SetupProgress : public Callback
+    {
+        Tick interval;
+        SetupProgress(Tick tick) : interval(tick) {}
+
+        virtual void process()
+        {
+            new ProgressEvent(&mainEventQueue, interval);
+            delete this;
+        }
+    };
+}
+
 /* check execute options */
 void
 ProgressParamContext::checkParams()
 {
     if (progress_interval.isValid())
-        new ProgressEvent(&mainEventQueue, progress_interval);
+        registerInitCallback(new SetupProgress(progress_interval));
 }