All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] clock_gettime() vs gettimeofday() have offset when run in real-time
@ 2017-03-30 17:35 Marco Camurri
  2017-04-01  9:21 ` Philippe Gerum
  0 siblings, 1 reply; 2+ messages in thread
From: Marco Camurri @ 2017-03-30 17:35 UTC (permalink / raw)
  To: xenomai

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Xenomai] clock_gettime() vs gettimeofday() have offset when run in real-time
  2017-03-30 17:35 [Xenomai] clock_gettime() vs gettimeofday() have offset when run in real-time Marco Camurri
@ 2017-04-01  9:21 ` Philippe Gerum
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Gerum @ 2017-04-01  9:21 UTC (permalink / raw)
  To: Marco Camurri, xenomai

On 03/30/2017 07:35 PM, Marco Camurri wrote:
> 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?
> 

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.

-- 
Philippe.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-01  9:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-30 17:35 [Xenomai] clock_gettime() vs gettimeofday() have offset when run in real-time Marco Camurri
2017-04-01  9:21 ` Philippe Gerum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.