[ntp:questions] how do I lock in average frequency correction
unruh at invalid.ca
Sun Feb 12 17:36:50 UTC 2012
On 2012-02-12, Ron Frazier (NTP) <timekeepingntplist at c3energy.com> wrote:
> Hi all,
> I've been reading around in the faq's at ntp.org and various pages
> googling around and cannot find obvious answers to these questions.
> It is my understanding that NTP is continuously making small changes to
> the software clock to keep the timing accurate while the os is running.
> 95% of the time, my computers are doing the same thing and 95% of the
> time, I'm doing the same thing with the computers. Therefore, over a
> long time interval, the interrupt usage should be similar, and over a
> long time interval, the correct clock frequency to maintain accuracy
> should be similar.
That above paragraph is not comprehensible to me. Yes, ntp is making
small changes to the software clock frequency.
What does your doing with the computer have to do with interrupt usage?
The clock crystal ages, and suffers internal crystal "cracks"
migrations, etc, which change the frequency of the crystal. Thus even in
a temperature controlled oven, the crystal frequency will change, but
much of the crystal frequency change is driven by temperature changes.
> So, what I want to do is figure out what the average frequency to keep
> accurate time is over say a week or month. I then want to fix the
> frequency at that level and leave it there. Then, under normal
> conditions, the clock should drift very little on average. If certain
> usage conditions, say transcoding a movie, make the clock drift more
> rapidly, I want it to step the time or slew it for that occasion, but
> not to alter the long term correction factor at all. That way, when my
> usage patterns return to normal, the drift should again return to a very
> slow rate.
Uh, that is what ntp tries to do, and is why it shifts up its poll
interval as time goes along ( and since it throws away 80% of
measurments, the effective poll interval is about 8 times as long as the
actual poll interval).
> I also would like to understand how ntp interacts with the Real Time
> Clock. I think I've read that either NTP or the OS (I don't know which)
It depends. ntp itself does not intereact with the real time clock at
all. However, under Linux, if the system clock thinks it is synced, it
resets te real time clock every 11 min to the system clock. also, in the
OS, hwclock is run at the end to reset the real time clock to the system
> will save the time to the RTC when shutting down and retrieve the time
> from the RTC when booting up. I'd like to know if this is true, first
> of all, and I'd like to know if it makes any corrections to the clock
> rate of the RTC so it is more accurate.
No. it does not, especially with that 11 minute mode, it cannot figure
out the rate of the clock. If you switch off the 11 min mode, by
constantly telling the system clock it is not in sync, then you can use
some versions of hwclock to measure the drift rate of the rtc.
But there is absolutely no way of altering the rate of the rtc without
unsoldering your clock crystal from the motherboard and putting in a new
one, or putting in a trimming capacitor, and adjusting it by hand.
> Any help is appreciated.
More information about the questions