TOD clock synchronization with NTP
Sergei Organov
osv at topconrd.ru
Tue Nov 4 17:03:48 UTC 2003
Till Straumann <strauman at SLAC.Stanford.EDU> writes:
> I'm thinking about how the RTEMS TOD clock could
> be kept synchronous with NTP. Without ever
> going back in time, of course.
As an interface I'd suggest:
void rtems_time_adjust(int ms);
Slowly adjust the time by 'ms' milliseconds. This adjustment can be
positive or negative. The system's clock will be sped up or slowed down
until it has drifted by the number of milliseconds specified.
Maybe think about even smaller granularity than milliseconds as time
synchronization at the level of a few microseconds seems to be feasible even
with current [micro]processors.
> The best idea I had so far, is introducing a 'slip_ticks' variable that gets
> set by the NTP client thread if the local clock needs to be adjusted
> backwards. _TOD_Tickle_ticks() would then, once in a while, decrement
> 'slip_ticks' and return without doing nothing.
And if slip_ticks is negative, then increment slip_ticks and do whatever it
does twice ;-)
>
> A better solution would be an adjustable hardware clock rate but that's
> hardly portable.
As a first implementation the above would probably work, then we can think of
some BSP-level interface to slow-down/speed-up system time. A lot of hardware
can do this, I believe.
--
Sergei.
More information about the users
mailing list