63 clock_getres (CLOCK_REALTIME, &ts);
134 return (int64_t)(nsNow - ns);
142 return -(int64_t)(ns - nsNow);
185 uint64_t numberJiffies = ns /
m_jiffy;
186 NS_LOG_INFO (
"Synchronize numberJiffies = " << numberJiffies);
208 if (numberJiffies > 3)
242 int64_t nsDrift =
DoGetDrift (nsCurrent + nsDelay);
250 NS_LOG_INFO (
"Back from SleepWait: IML8 " << nsDrift);
260 NS_LOG_INFO (
"SpinWait until " << nsCurrent + nsDelay);
261 return SpinWait (nsCurrent + nsDelay);
368 uint64_t correction = (uint64_t)drift;
369 if (correction <= nsDelay)
371 return nsDelay - correction;
383 struct timeval tvNow;
384 gettimeofday (&tvNow, NULL);
417 struct timeval *result)
420 result->tv_sec = tv1->tv_sec + tv2->tv_sec;
421 result->tv_usec = tv1->tv_usec + tv2->tv_usec;
#define NS_LOG_FUNCTION(parameters)
#define NS_ASSERT(condition)
uint64_t TimevalToNs(struct timeval *tv)
static const uint64_t NS_PER_SEC
void Signal(void)
Release one thread if waiting for the condition to be true.
static const uint64_t US_PER_NS
uint64_t GetRealtime(void)
virtual int64_t DoGetDrift(uint64_t ns)
Declaration of method used to retrieve drift between the real time clock used to synchronize the simu...
virtual bool DoRealtime(void)
Return true if this synchronizer is actually synchronizing to a realtime clock.
void SetCondition(bool condition)
Set the value of the underlying condition.
virtual uint64_t DoGetCurrentRealtime(void)
Retrieve the value of the origin of the underlying normalized wall clock time in nanosecond units...
virtual bool DoSynchronize(uint64_t nsCurrent, uint64_t nsDelay)
Wait until the real time is in sync with the specified simulation time.
NS_LOG_COMPONENT_DEFINE("WallClockSynchronizer")
bool GetCondition(void)
Get the value of the underlying condition.
virtual ~WallClockSynchronizer()
bool TimedWait(uint64_t ns)
Wait a maximum of ns nanoseconds for the condition to be true.
virtual void DoSetOrigin(uint64_t ns)
Establish a correspondence between a simulation time and a wall-clock (real) time.
static const uint64_t US_PER_SEC
uint64_t m_realtimeOriginNano
virtual void DoEventStart(void)
virtual void DoSetCondition(bool cond)
Declaration of the method used to set the condition variable that tells a possible simulator thread w...
void NsToTimeval(int64_t ns, struct timeval *tv)
void TimevalAdd(struct timeval *tv1, struct timeval *tv2, struct timeval *result)
SystemCondition m_condition
uint64_t GetNormalizedRealtime(void)
virtual void DoSignal(void)
Declaration of the method used to tell a possible simulator thread waiting in the DoSynchronize metho...
virtual uint64_t DoEventEnd(void)
uint64_t DriftCorrect(uint64_t nsNow, uint64_t nsDelay)