I previously posted:
>> How are negative time amounts supposed to be represented in struct
>> timeval tv_usec for calls to adjtime(2)? The man pages, #include files,
>> and the web pages turned up by my Google searches aren't clear to me.
Lowell Gilbert <
lgus...@be-well.ilk.org> kindly replied:
> Um, yeah, everybody just uses the POSIX manal pages, which are rather
> minimal. Part of the problem is that adjtime() exists primarily to be
> used by NTP, and normally the interface to it is to use an ntpd.
Solaris/SunOS used to have "date -a S.s", but, yes, FreeBSD's date
doesn't.
> Also, what adjtime() does internally depends on a lot of parameters,
> many of which aren't visible outside of the kernel. Again, see RFC5905.
>> Experimental results with adjtime suggest something curious: Repeated
>> calls with, say, -7 -.25 seem to slow time by more than repeated calls
>> with -7 -.50.
> Repeated calls? How often? What kind of timing discipline are you using?
Once a day or less for many days; not rapidly (where the previous call
might not yet have completed and adjtime() reports an amount not yet
adjusted). I check the adjtime return value to ensure that there was no
adjustment not yet finished.
>> Anyone know what adjtime() actually wants for tv_usec for negative
>> adjustment values?
> It seems to do a lot of conversions of its own, so I don't think that
> matters, really.
If adjtime or any other system call has a preference for how negative
times should be specified, it'd be nice to say which format it/they
prefer, in the man page or at least in <sys/_timeval.h>.
> What are you trying to do, anyway?
Compare computer clock speed against wall clock time over many months
and adjust the clock manually (via periodic calls) rather than use ntpd.
(E.g., for a stand-alone system.)
> For one thing, seven or eight seconds is a large change to slew; it
> wouldn't complete for days.
That's not what I've seen with FreeBSD 8, 9, 10, or 11. Adjustments of
even 40-50 seconds have happened in a few hours.
I just ran a test, checking occasionally:
14:21: I did adjtime of -8.0 seconds.
14:48: it had corrected about -7 seconds.
14:53: the adjustment looked complete.
Elapsed time: about 32 minutes, so ~1/4 second per minute.
-WBE