* [Xenomai-help] clock drift
@ 2008-10-02 5:30 Rob Wheeler
2008-10-02 5:38 ` Gilles Chanteperdrix
2009-01-14 21:26 ` Gilles Chanteperdrix
0 siblings, 2 replies; 6+ messages in thread
From: Rob Wheeler @ 2008-10-02 5:30 UTC (permalink / raw)
To: xenomai
Hello,
I was recently debugging a problem in our code base and tracked the
issue down to differences between calling gettimeofday() from our
non-realtime code and calling clock_gettime() from our realtime
control loop. A little poking around with Google led me to clocktest
program in the Xenomai testsuite. We are routinely seeing differences
of around 4 minutes (~240 seconds) between gettimeofday() and
clock_gettime() immediately after a reboot. The clocks continue to
drift apart (or together) at the rate of about 50us/s.
My question is, is this large of a disparity between clocks normal?
Are there any tricks or techniques for getting the clocks to be
synchronized? In our application we have a realtime control loop
reading data from motor control boards at a rate of 1KHz. The data is
timestamped by the realtime loop. The non-realtime code can doing
more heavyweight computation on that data. It uses the timestamp to
correlate the data with other data read from non-realtime sensors
(cameras, laser scanners, etc...). Some of this data may even be
collected on other computers running on the robot (and connected via
gigabit Ethernet). What do others do to synchronize time between
realtime, non-realtime, and other network attached computers?
A little more about my setup:
kernel - 2.6.24.3
xenomai - v2.4.5
adeos patch - adeos-ipipe-2.6.24-x86-2.0-07.patch
processor - 2.5 GHz Core 2 Duo
Thanks for any info you can provide...
-R
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Xenomai-help] clock drift
2008-10-02 5:30 [Xenomai-help] clock drift Rob Wheeler
@ 2008-10-02 5:38 ` Gilles Chanteperdrix
[not found] ` <894886ec0810012258o67da00d7x2e3d54c7e601b470@domain.hid>
2009-01-14 21:26 ` Gilles Chanteperdrix
1 sibling, 1 reply; 6+ messages in thread
From: Gilles Chanteperdrix @ 2008-10-02 5:38 UTC (permalink / raw)
To: Rob Wheeler; +Cc: xenomai
Rob Wheeler wrote:
> Hello,
>
> I was recently debugging a problem in our code base and tracked the
> issue down to differences between calling gettimeofday() from our
> non-realtime code and calling clock_gettime() from our realtime
> control loop. A little poking around with Google led me to clocktest
> program in the Xenomai testsuite. We are routinely seeing differences
> of around 4 minutes (~240 seconds) between gettimeofday() and
> clock_gettime() immediately after a reboot. The clocks continue to
> drift apart (or together) at the rate of about 50us/s.
>
> My question is, is this large of a disparity between clocks normal?
> Are there any tricks or techniques for getting the clocks to be
> synchronized? In our application we have a realtime control loop
> reading data from motor control boards at a rate of 1KHz. The data is
> timestamped by the realtime loop. The non-realtime code can doing
> more heavyweight computation on that data. It uses the timestamp to
> correlate the data with other data read from non-realtime sensors
> (cameras, laser scanners, etc...). Some of this data may even be
> collected on other computers running on the robot (and connected via
> gigabit Ethernet). What do others do to synchronize time between
> realtime, non-realtime, and other network attached computers?
>
> A little more about my setup:
> kernel - 2.6.24.3
> xenomai - v2.4.5
> adeos patch - adeos-ipipe-2.6.24-x86-2.0-07.patch
> processor - 2.5 GHz Core 2 Duo
>
> Thanks for any info you can provide...
Xenomai has no (not yet, this may come) way to correct the clock drift
progressively, like the linux kernel does when using NTP, however, since
version 2.4.x, Xenomai supports setting the clock with clock_settime.
So, as a workaround, you can call clock_settime periodically to
resynchronize Xenomai clock with Linux clock.
Pay attention however: setting the clock has an influence on timers
(like the posix spec asks), so when doing this, you have to carefully
choose whether your timers use CLOCK_REALTIME or CLOCK_MONOTONIC and
whether they are absolute or relative.
http://www.opengroup.org/onlinepubs/000095399/functions/clock_settime.html
--
Gilles.
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [Xenomai-help] clock drift
2008-10-02 5:30 [Xenomai-help] clock drift Rob Wheeler
2008-10-02 5:38 ` Gilles Chanteperdrix
@ 2009-01-14 21:26 ` Gilles Chanteperdrix
1 sibling, 0 replies; 6+ messages in thread
From: Gilles Chanteperdrix @ 2009-01-14 21:26 UTC (permalink / raw)
To: Rob Wheeler; +Cc: xenomai
Rob Wheeler wrote:
> Hello,
>
> I was recently debugging a problem in our code base and tracked the
> issue down to differences between calling gettimeofday() from our
> non-realtime code and calling clock_gettime() from our realtime
> control loop. A little poking around with Google led me to clocktest
> program in the Xenomai testsuite. We are routinely seeing differences
> of around 4 minutes (~240 seconds) between gettimeofday() and
> clock_gettime() immediately after a reboot. The clocks continue to
> drift apart (or together) at the rate of about 50us/s.
Hi Rob,
when chasing unrelated issues, I found what could be the cause of the
original 4 minutes difference. The bug is fixed in the svn repository. I
think it goes in the "very stupid bugs" category.
Well, tooks only 3 monthes...
Regards.
--
Gilles.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-01-14 21:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-02 5:30 [Xenomai-help] clock drift Rob Wheeler
2008-10-02 5:38 ` Gilles Chanteperdrix
[not found] ` <894886ec0810012258o67da00d7x2e3d54c7e601b470@domain.hid>
2008-10-02 6:05 ` Gilles Chanteperdrix
2008-10-02 7:45 ` Theo Veenker
2008-10-02 8:23 ` Gilles Chanteperdrix
2009-01-14 21:26 ` Gilles Chanteperdrix
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.