[ntp:questions] PHK on Ntimed and Chrony

William Unruh unruh at invalid.ca
Mon Feb 16 06:18:44 UTC 2015


On 2015-02-15, Terje Mathisen <terje.mathisen at tmsw.no> wrote:
> William Unruh wrote:
>> incorporated into ntpd. I like chrony's ease of using intermittent time
>> sources and also its disciplining of the rtc as well as the system
>> clock, although it is not as useful as it could be since the rtc is
>> greatest use when the computer is shut off and cold, while the estimate
>> of it drift rate is done while it is running and hot. Are there any
>> ideas as to how that could be better done than it is in chrony?
>
> That one is pretty obvious: I wrote code around 1985 or so which sampled 
> the CMOS clock with one-day intervals (using a dial-up time source as my 
> reference).

I did say better than chrony. 

>
> After just 24 hours (i.e. with two samples) I let it free-run for a 
> week, when I tried again I found that the eventual offset was around 0.1 
> second, which might have been partly luck, but definitely a huge 
> improvement.

So about .5PPM Not bad. 
>
> For an RTC improved estimate I would use the last sample (i.e. the last 
> time the current system clock was written back to the rtc, something 
> that usually happens once per hour, and then check the first external 

Nope, once every 11 min by the kernel if the system clock is marked as
synchronized. 

> sync after system restart: At this point the system clock will be rtc 
> based and the measured offset divided by the time since the last rtc 
> update is a good estimate of the rtc drift rate.

At that time. Unfortunately just like computer clock crystals, the drift
rate of the rtc tends to change. 

chrony measures the rtc and calculates its drift rate and its offset
continuously, (It has to disable the kernel's 11 min writing to do that
since that would mess up all measurements) and writes them to a file,
which chrony uses when next it is started up to estimate how far out the
rtc is. Ie, something like what you suggest. Except as I said, it is
measured when the computer is hot, and used when it is cold ( and when
there are no measurements to say how cold it is since the computer is
off.)



More information about the questions mailing list