Subject: Re: settimeofday() versus interval tim{ers,ing}
To: Jonathan Stone <jonathan@dsg.stanford.edu>
From: Dennis Ferguson <dennis@jnx.com>
List: tech-kern
Date: 09/29/1996 21:17:06
Whoops, finger slip.
> One plausible answer is to never, ever use settimefoday(), except
> immediatley after booting. I use NTP, which usually steps the system
> clock with settimeofday *once*, at boot time, and slews it via
> ntp_adjtime() thereafter.
>
> Why do you need to call settimeofday()?
> Is it, perhaps, because you're running timed?
No, it's NTP.
The machine in question is a router. It can't set its time until it can
reach an NTP server, which it can't in general do until it is running the
routing protocols to populate its forwarding table. Once the routing is
running it can set the time. Unfortunately, if the time is way off from
boot (like the hardware RTC is set to PDT rather than UTC), setting the
time hoses the process running the routing due to interval timer death.
And this is kind of the point. Never calling settimeofday() is nice, but
if the machine does manage to boot with a funky time and start processes,
or the time is off for whatever reason, shouldn't you be able to fix it
by calling settimeofday() without hosing things that couldn't care less about
the time of day?
I am actually somewhat familiar with NTP (I wrote the original xntpd, you
might still find my name on the man page), and I think it would be naive
to think that a process which is trying to maintain your time will always
behave in a reasonable fashion. This is the point. I want ntp to step
the clock when it thinks it is way off, if the time is wrong I'd like it
fixed. I just don't think it should break things which have nothing to
do with time of day, if the damage were limited to cron I'd be happy.
Dennis Ferguson