Timesync: Make sure timesync event is setup after curTick is unserialized

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.
This commit is contained in:
Ali Saidi 2011-02-11 18:29:35 -06:00
parent b7457fc11e
commit 59bf0e7eb4
2 changed files with 28 additions and 2 deletions

View 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 *

View 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__