clock_gettime() vs gettimeofday() have offset when run in real-time
Dear all,
I need to get the wallclock time from a real-time thread under Xenomai 2.6.4 running on a x86_64 architecture with Ubuntu 14.04
After realizing that calling the function gettimeofday() I was creating mode switches, I've replaced the call with the clock_gettime() (this one: http://www.xenomai.org/documentation/trunk/html/api/group__posix__time.html#ga10b73e75d375e5c244e32ea46be775bf)
with the parameter CLOCK_REALTIME.
Unfortunately, when comparing the value returned by the call of clock_gettime() from within the real-time thread and the gettimeofday() called from a non-realtime thread, they turned out to be about 6 seconds apart.
when running a single non real-time thread with both functions called, they return the same value.
Is there a way to have the same behavior of gettimeofday from within a real-time thread without having mode switches?
Thanks,
Marco.
Quoted 18 lines · Marco Camurri
Dear all,
I need to get the wallclock time from a real-time thread under Xenomai 2.6.4 running on a
x86_64architecture with Ubuntu 14.04After realizing that calling the function
gettimeofday()I was creating mode switches, I've replaced the call with theclock_gettime()(this one:
http://www.xenomai.org/documentation/trunk/html/api/group__posix__time.html#ga10b73e75d375e5c244e32ea46be775bf)with the parameter
CLOCK_REALTIME.Unfortunately, when comparing the value returned by the call of
clock_gettime()from within the real-time thread and thegettimeofday()called from a non-realtime thread, they turned out to be about 6 seconds apart.
Quoted 6 lines
when running a single non real-time thread with both functions called, they return the same value.
Is there a way to have the same behavior of gettimeofday from within a real-time thread without having mode switches?
CLOCK_REALTIME is based on the epoch maintained by the real-time core, which is distinct from the epoch maintained by the Linux kernel. You need CLOCK_HOST_REALTIME.
Signature · 1 line
Philippe.