Subject: why times are often off by up to a second
To: None <tech-kern@netbsd.org>
From: Perry E. Metzger <perry@piermont.com>
List: tech-kern
Date: 02/24/1999 10:00:48
Ever notice how, on many NetBSD ports (i386 is one, but there are
others) when you boot up and poll your ntp server, you're off by half
a second or .9 seconds or what have you, even though mere moments
before you rebooted you were precisely in sync?

Well, the reason is fairly obvious in retrospect. Our battery backed
up clocks on most ports have an ACCURACY of much greater than one
second, but only a RESOLUTION of one second. Thus, when we boot up and
set the TOD clock from the battery backed up hardware clock in
inittodr(), we may be off by as much as (nearly, but not quite) one
second -- similarly, when we do the inverse operation in resettodr(),
we can be off by as much as (nearly, but not quite) one second.

I've been thinking about a bunch of ways to fix this nit, but most of
them involve spinning for up to one second, which isn't really a good
idea. I was therefore wondering if people on tech-kern had any
opinions on the "correct" method.

Perry