Subject: Re: How to tweak clock rate
To: None <current-users@NetBSD.ORG>
From: Ken Hornstein <>
List: current-users
Date: 03/28/1998 02:08:57
>All of this ``pleasant discussion'' about NTP (on tech-kern) has gotten
>me interested in trying to make my clock more accurate. I've got a
>386/33 running NetBSD 1.3E, and its clock seems to run way fast. I run
>ntpdate each time I connect to my ISP, and it looks like my clock gets
>ahead about 3 seconds in 2 hours. Is there anything I can do to fix

I have heard of people that replace their clock crystal with one more
accurate (10 ppm is a figure I've heard).  It's my understanding that
the crystal you want to replace on the i386 is the one used by the PIT,
which should be something close to 14,317,180 Hz.  Of course, that
assumes the crystal in question is socketed, or you're handy with a
soldering iron ...

>I get the impression that I'm supposed to use tickadj to change tick a
>bit... is this the same as the tick in the kern.clockrate sysctl? If so,
>how do I change it? There's no tickadj and sysctl says kern.clockrate
>isn't changeable. (and I tried sysctl -w kern.clockrate=9999, which
>didn't work)

I believe that's just changing the number of ticks per second, which
is (as I understand it ... and I could be wrong) is how time is stored
in the kernel.  The kernel calcuates how many ticks need to be added
to the timer for every clock interrupt; depending on how you set
this, NTP adjustments can be done more accurately (so I'm told ... I'm
not completely clear on this theory either :-) ).  This stuff is
all in /sys/arch/i386/isa/clock.c, if you're interested.

Since presumably your biggest problem is that your clock crystal
isn't exactly what it's supposed to be, you could try defining a
new value for TIMER_FREQ (/sys/arch/i386/isa/timerreg.h), based on
your calculated time drift.  This calculation should be straightforward,
but since it's late, I don't feel like doing it :-)