home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / sun / misc / 3308 < prev    next >
Encoding:
Text File  |  1992-07-23  |  1.9 KB  |  70 lines

  1. Newsgroups: comp.sys.sun.misc
  2. Path: sparky!uunet!ossi!aegl
  3. From: aegl@ossi.com (Tony Luck)
  4. Subject: Re: adjtime(2)
  5. Message-ID: <aegl.711915476@ossi.com>
  6. Sender: news@ossi.com (OSSI Newsstand)
  7. Nntp-Posting-Host: nym
  8. Organization: Open Systems Solutions Inc.
  9. References: <1130@racerx.bridge.COM>
  10. Date: Thu, 23 Jul 1992 18:17:56 GMT
  11. Lines: 57
  12.  
  13. ken@bridge.COM (Ken Hardy) writes:
  14. >Q1: Is the time adjustment amount in an adjtime(2) call added to any
  15. >    remaining adjustment from a previous call, or does it supercede
  16. >    it, replacing it as an absolute value?
  17.  
  18. >    If it is cumulative, I need to know the remaining value so that I
  19. >    don't blindly whipsaw the clock around when trying to make an
  20. >    adjustment when a previous one is still taking effect.
  21.  
  22. >Q2: Is the adjtime(2) call known to not work as advertised?  I'm
  23. >    running SunOS 4.1.1 on a ss1 and SunOS 4.0 on a 386i.
  24.  
  25. If you are trying to keep in sync with an external real clock on a SunOS
  26. system you should use adb to patch the variable "dosynctodr" to be zero.
  27. If you don't, SunOS will keep trying to sync with its battery calendar
  28. chip.
  29.  
  30. A1. Calls to adjtime(2) should supercede  earlier calls.
  31.  
  32. A2. I built the 4.3bsd "timed" on 4.1.1 on a SPARCstation2 ... and adjtime
  33.     seemed to work for me.  I have no idea why you always see the previous
  34.     adjustment as zero.  Here is a little program I wrote once to play
  35.     with adjtime:
  36.  
  37. #include <stdio.h>
  38. #include <sys/types.h>
  39. #include <sys/time.h>
  40.  
  41. int
  42. main(argc, argv)
  43.     int    argc;
  44.     char    **argv;
  45. {
  46.     struct    timeval    new, old;
  47.     time_t    now;
  48.  
  49.     if (argc > 2) {
  50.         fprintf(stderr, "Usage: %s [ adjustment ]\n", argv[0]);
  51.         return 1;
  52.     }
  53.     new.tv_sec = (argc > 1) ? atoi(argv[1]) : 0;
  54.     new.tv_usec = 0;
  55.  
  56.     if (adjtime(&new, &old) == -1) {
  57.         perror("adjtime");
  58.         return 1;
  59.     }
  60.     if (argc == 1 || old.tv_sec != 0 || old.tv_usec != 0)
  61.         printf("Old adjustment was %d.%.6d\n", old.tv_sec, old.tv_usec);
  62.  
  63.     if (argc == 1)
  64.         adjtime(&old, &new);
  65.  
  66.     return 0;
  67. }
  68.  
  69. -Tony Luck <aegl@ossi.com>
  70.