I'm curious about an implementation detail of programs like
chrony and ntpd.  I'm sure there are people on this list who
can answer; I hope it's not too inappropriate to ask here.

If you're a program like chrony or ntpd, it seems to me you'd
want a data structure which can represent a clock: either your
own that you're managing, or each of your possibly several
sources.  So my question is simply, what sort of data structure
do you use to represent a clock?  The challenge, of course, is
that this is not a data structure that simply stores a piece of
data -- it has to represent the concept of a time-varying piece
of data.

My first thought is that you could represent a clock as an offset
and perhaps a rate scale with respect to your own OS clock.  That
runs into difficulties if your own OS clock changes (which it's
bound to do, if you're managing it!).  Any changes you yourself
make, you could account for, but if someone else sets the OS
clock out from under you, it could completely stymie things.

So my second thought is that you could represent a clock as a
scale and an offset on top of a monotonic OS clock, perhaps
clock_getting(CLOCK_MONOTONIC).  There would be additional
complications if the rate of that monotonic clock were to change,
so this might be an opportunity to use the Linux-specific
CLOCK_MONOTONIC_RAW.

But enough speculation.  Can anyone explain how chrony and ntpd
actually do this?  Or does the question not make sense; am I
misunderstanding the mechanism these programs actually use
to manage their clock sources and their relationship to the
locally-managed clock?

I've been curious about this for a long tine.  Thanks for any
hints or explanations anyone can provide.

Steve Summit

-- 
To unsubscribe email [email protected] with "unsubscribe" 
in the subject.
For help email [email protected] with "help" in the 
subject.
Trouble?  Email [email protected].

Reply via email to