mirror of
https://github.com/wjwwood/serial.git
synced 2026-01-22 11:44:53 +08:00
on Linux, use CLOCK_MONOTONIC for clock_gettime()
On Linux systems which are being driven by an external time source (NTP or PTP), it is possible that time appears to slew in reverse under `CLOCK_REALTIME`. Since the timer function is used to time durations of events (calls to `select()`), it is better to use `CLOCK_MONOTONIC`, which isn't subject to slewing.
This commit is contained in:
parent
ef7f77d411
commit
98f1c31e81
@ -91,7 +91,7 @@ MillisecondTimer::timespec_now ()
|
||||
time.tv_sec = mts.tv_sec;
|
||||
time.tv_nsec = mts.tv_nsec;
|
||||
# else
|
||||
clock_gettime(CLOCK_REALTIME, &time);
|
||||
clock_gettime(CLOCK_MONOTONIC, &time);
|
||||
# endif
|
||||
return time;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user