Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

adjtime: How does it work?

1 view
Skip to first unread message

glen_andrews

unread,
Nov 11, 1996, 3:00:00 AM11/11/96
to

I wish to use adjtime to adjust the system time, but have been unable to
determine the following:

Is there a maximum adjustment adjtime will accept?

What happens when I call adjtime, and the previous adjustment is not complete,
Is the new adjustment discarded, or is the old one lost?

Are there any side-effects to calling adjtime?

Is adjtime better than calling settimeofday?

How do I know when adjtime is complete, and how can I check to see if it did the
adjustment? I'm trying to use gettimeofday, but I don't see the adjustment.

Thanks for any help,
Glen Andrews
gand...@seas.gwu.edu

Thomas R. Truscott

unread,
Nov 12, 1996, 3:00:00 AM11/12/96
to

>Is there a maximum adjustment adjtime will accept?

Some systems won't accept adjustments larger than MAXLONG/1000000 seconds
(about half an hour). That is due to a stupid implementation.

>What happens when I call adjtime, and the previous adjustment is not complete,
>Is the new adjustment discarded, or is the old one lost?

The new adjustment takes effect and the old one is "lost".
(The remaining old adjustment is returned as olddelta.)
To avoid that you can call adjtime() with a NULL delta and
add the olddelta to the new adjustment
and then call adjtime() with the adjusted new adjustment.

>Are there any side-effects to calling adjtime?

Well, the clock might start running faster or slower,
if the call fails it will set errno,
the call will consume CPU time,
in some implementations the call is logged if system call
tracing is in effect. Stuff like that.

>Is adjtime better than calling settimeofday?

Much better, because the clock does not abruptly jump forwards
or (much worse) backwards. This is best for small adjustments.
Use settimeofday() if the current clock is off by a year!

Call adjtime() with a NULL delta and consult the olddelta.
Please also re-read the man page.

Good luck.
Tom Truscott

Logan Shaw

unread,
Nov 15, 1996, 3:00:00 AM11/15/96
to

In article <56adlt$l...@hal.cs.duke.edu>,

Thomas R. Truscott <t...@cs.duke.edu> wrote:
>>Are there any side-effects to calling adjtime?
>
>Well, the clock might start running faster or slower,
>if the call fails it will set errno,
>the call will consume CPU time,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Uhoh! Wouldn't want _that_.

- Logan
Who wants an version of sleep() that accepts negative numbers:

$ at now + 1 day
at> cd /var/spool/news
at> tar cf - ./misc/headlines | (sleep -86400 ; cat > /tmp/foo.tar)
at> ^D
$
--
Logan Shaw, Unix Systems Administrator
"everybody / loves to see / justice done / on somebody else" (Bruce Cockburn)

0 new messages