Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: "dmesg -T" date doesn't match "date" output

    Date:        Tue, 30 Oct 2018 12:31:02 -0700
    From:        Dennis Ferguson <>
    Message-ID:  <>

You might, or might not depending which lists you read, have noticed that
I was working on this about the same time you were sending this message.

  | Note that time_second(9) says boottime is â??the system boot timeâ?? (in UTC,
  | implicitly) while uptime is â??the time elapsed since bootâ??. I believe this
  | unambiguously defines boottime to be the (UTC) time when uptime was zero;
  | boottime is uptimeâ??s epoch. This doesnâ??t mean that boottime needs to be
  | set when uptime is zero, it just means that when boottime is set it needs
  | to be set to (time(now) - uptime(now)) rather than just time(now). That it
  | is initialized to the latter is the bug.

Yes, I think we came to that conclusion, and that is what I changed.

  | It may be worth pointing out that the code in kern/kern_tc.c is written to
  | maintain the identity
  |     time = uptime + boottime
  | at all times, except that it instead maintains a local version of boottime
  | in the local variable timebasebin.

I knew the intended relationship, and noticed that code, but as most of
kern_tc.c is black art to me, I thought I'd  just trust that all that was 
correct, and leave it all alone!

  | I suspect the easiest way to fix the bug would be to eliminate the
  | independent initialization and maintenance of the boottime variable in
  | init_main.c and kern_time.c in favor of adding a
  |      bintime2timespec(&timebasebin, &boottime);
  | after timebasebin is updated in kern_tc.c:tc_setclock(). The code that
  | manipulates boottime outside of kern_tc.c is actually a leftover vestige
  | of the clock support code prior to timecounters that probably should have
  | disappeared when the latter was implemented.

Makes sense, and if someone wants to do that, then by all means...  (For me
it was easied to simply correct the init of  boottime.)

  | As a quibble, the code in kern_todr.c:inittodr() could probably be improved

No comment on that one.   Almost all code can be improved.

  | so calling
  |     tc_setclock(filesystemtime + uptime(now) + maybe_a_fudge_factor)
  | would produce a time(now) that is at least a few seconds closer to reality.

Yes, it would I think, so instead of being (say) 8 hours out, it will be 7 hours, 59 
mins, and 54 seconds...    Is that really worth the bother?


Home | Main Index | Thread Index | Old Index