[Xenomai] clock_gettime() vs gettimeofday() have offset when run in real-time

Marco Camurri marco.camurri at iit.it
Thu Mar 30 19:35:35 CEST 2017

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 

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 

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?


More information about the Xenomai mailing list