home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.sun.misc
- Path: sparky!uunet!ossi!aegl
- From: aegl@ossi.com (Tony Luck)
- Subject: Re: adjtime(2)
- Message-ID: <aegl.711915476@ossi.com>
- Sender: news@ossi.com (OSSI Newsstand)
- Nntp-Posting-Host: nym
- Organization: Open Systems Solutions Inc.
- References: <1130@racerx.bridge.COM>
- Date: Thu, 23 Jul 1992 18:17:56 GMT
- Lines: 57
-
- ken@bridge.COM (Ken Hardy) writes:
- >Q1: Is the time adjustment amount in an adjtime(2) call added to any
- > remaining adjustment from a previous call, or does it supercede
- > it, replacing it as an absolute value?
-
- > If it is cumulative, I need to know the remaining value so that I
- > don't blindly whipsaw the clock around when trying to make an
- > adjustment when a previous one is still taking effect.
-
- >Q2: Is the adjtime(2) call known to not work as advertised? I'm
- > running SunOS 4.1.1 on a ss1 and SunOS 4.0 on a 386i.
-
- If you are trying to keep in sync with an external real clock on a SunOS
- system you should use adb to patch the variable "dosynctodr" to be zero.
- If you don't, SunOS will keep trying to sync with its battery calendar
- chip.
-
- A1. Calls to adjtime(2) should supercede earlier calls.
-
- A2. I built the 4.3bsd "timed" on 4.1.1 on a SPARCstation2 ... and adjtime
- seemed to work for me. I have no idea why you always see the previous
- adjustment as zero. Here is a little program I wrote once to play
- with adjtime:
-
- #include <stdio.h>
- #include <sys/types.h>
- #include <sys/time.h>
-
- int
- main(argc, argv)
- int argc;
- char **argv;
- {
- struct timeval new, old;
- time_t now;
-
- if (argc > 2) {
- fprintf(stderr, "Usage: %s [ adjustment ]\n", argv[0]);
- return 1;
- }
- new.tv_sec = (argc > 1) ? atoi(argv[1]) : 0;
- new.tv_usec = 0;
-
- if (adjtime(&new, &old) == -1) {
- perror("adjtime");
- return 1;
- }
- if (argc == 1 || old.tv_sec != 0 || old.tv_usec != 0)
- printf("Old adjustment was %d.%.6d\n", old.tv_sec, old.tv_usec);
-
- if (argc == 1)
- adjtime(&old, &new);
-
- return 0;
- }
-
- -Tony Luck <aegl@ossi.com>
-