ntpd and cmos clock update

From: Andriy Gapon (avg_at_icyb.net.ua)
Date: 08/28/05

  • Next message: Bharath Bhushan: "interrupt handlers - FreeBSD 4.9"
    Date: Sun, 28 Aug 2005 16:35:41 +0300
    To: freebsd-hackers@freebsd.org
    
    

    I think I saw more than once speculations that FreeBSD updates CMOS
    clock when time is set, so CMOS clock value should always be very close
    to internal OS timer. But I always took it with a grain of salt because
    every time I reboot after long uptime period I see messages from ntpd
    about adjusting clock by many seconds and such discrepancy should not
    occur, of course, during couple of minutes that reboot takes. Recently
    this question (re-)surfaced in Russian language BSD newsgroup and I
    thought that a wider community might be interested.

    It seems that CMOS clock is updated using resettodr(9) function. There
    seem to be only a few occasions when this function is called:

    1. clock_settime(ClOCK_REALTIME) // through kern_time.c:settime()
    2. settimeofday() // through kern_time.c:settime()
    3. machdep.adjkerntz sysctl is set

    I believe that ntpd calls settime-family functions only if time offset
    is larger than 128ms (or maybe I am thinking about ntpdate), but
    normally it uses ntp_adjtime() to adjust time keeping. Obviosuly, a
    system running ntpd with good enough hardware clock and good enough
    connection to good enough ntp server(s) would use the latter method all
    of the time after some initial stabilization period. But it seems that
    time changes are never propagated to CMOS in this case, thus leading to
    behavior mentioned in the beginning.

    This is not a big problem, of course, but quite an annoyance
    (sometimes). I wonder what could be the best solution to this issue. One
    idea is to always update CMOS from adjkerntz(8) upon shutdown/reboot,
    but this would not help if system crashes, but adjkerntz could also do
    it periodically.

    Any ideas ? Is it worth concern at all ?

    -- 
    Andriy Gapon
    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
    

  • Next message: Bharath Bhushan: "interrupt handlers - FreeBSD 4.9"

    Relevant Pages

    • Re: OT: Re: Computer loosing time
      ... Time on the desktops are configured for ntp via pool.ntp.org servers, ... comments regarding the CMOS battery. ... dead CMOS battery _Ubuntu_ will run fine. ... My CMOS clock and battery are both perfectly fine. ...
      (Ubuntu)
    • Re: Is the x86 clock stoppable?
      ... At the time I was told that CMOS ... to be used instead of the power or reset button as ... If you want a stop clock x86, ...
      (comp.arch)
    • Re: Computer loosing time
      ... looses about 5 seconds per hour (note that the CMOS clock remains on the ... The CMOS battery can be dead as a doornail (where did that term ... a bother to tear the laptop apart and replace it, so I just set it at ...
      (Ubuntu)
    • Re: The ext3 way of journalling
      ... But the cmos clock displays the right time.) ... That doesn't mean that system clock was correct at the time ... What happens later is that distribution init scripts will adjust the ...
      (Linux-Kernel)