Timesync: Make sure timesync event is setup after curTick is unserialized
authorAli Saidi <Ali.Saidi@ARM.com>
Sat, 12 Feb 2011 00:29:35 +0000 (18:29 -0600)
committerAli Saidi <Ali.Saidi@ARM.com>
Sat, 12 Feb 2011 00:29:35 +0000 (18:29 -0600)
Setup initial timesync event in initState or loadState so that curTick has
been updated to the new value, otherwise the event is scheduled in the past.

src/sim/root.cc
src/sim/root.hh

index 1dc9b605865b4809f09271f3b19cbfb8ee73dda5..d51fcbda60cc729586b9a2abd04e61c4c34f4c82 100644 (file)
@@ -108,7 +108,18 @@ Root::Root(RootParams *p) : SimObject(p), _enabled(false),
     assert(_root == NULL);
     _root = this;
     lastTime.setTimer();
-    timeSyncEnable(p->time_sync_enable);
+}
+
+void
+Root::initState()
+{
+    timeSyncEnable(params()->time_sync_enable);
+}
+
+void
+Root::loadState(Checkpoint *cp)
+{
+    timeSyncEnable(params()->time_sync_enable);
 }
 
 Root *
index 2beced9d4aae7c8c1d984fee1832367a7e4c875b..76a508c19482201e5770501cee1e6f65adf9dd29 100644 (file)
@@ -95,7 +95,22 @@ class Root : public SimObject
     /// Set the threshold for time remaining to spin wait.
     void timeSyncSpinThreshold(Time newThreshold);
 
-    Root(RootParams *p);
+    typedef RootParams Params;
+    const Params *
+    params() const
+    {
+        return dynamic_cast<const Params *>(_params);
+    }
+
+    Root(Params *p);
+
+    /** Schedule the timesync event at loadState() so that curTick is correct
+     */
+    void loadState(Checkpoint *cp);
+
+    /** Schedule the timesync event at initState() when not unserializing
+     */
+    void initState();
 };
 
 #endif // __SIM_ROOT_HH__