Re: advice on how to detect time change



John Reiser <jreiser@xxxxxxxxxxxx> writes:
d_cymbal@xxxxxxxxxxx wrote:
Perhaps I didn't phrase that question correctly. My application
doesn't care what the system time is, or care that it is correct, but
it does need to detect if some external entity changes the time out
from under it (this is a master device which must globally update
slave devices with a time change if the user (or some other force such
as ntp) changes the time on the master system. The process itself
doesn't rely on or care what the system time is, it just needs to
detect changes.

There is a design error in your application. It is trying to measure
intervals by subtracting time values.

This is perfectly ok in absence of 'sysadmin interventions' to change
the clock to a new value.

This cannot work reliably ANY system, not just Linux. The time is
the closest known approximation to the value of some counter at your
[government] Standards facility.

This is not correct. The actual definition is

Seconds Since the Epoch

A value that approximates the number of seconds that have elapsed
since the Epoch.

[...]

How any changes to the value of seconds since the Epoch are
made to align to a desired relationship with the current
actual time is implementation-defined.

Further, it is supposed to be counted in UTC. For Linux, more specific
documentation exists, namely time(7):

Real time and process time

Real time is defined as time measured from some fixed
point, either from a standard point in the past

[...]

The Hardware Clock

Most computers have a (battery-powered) hardware clock which
the kernel reads at boot time in order to initialize the
software clock.

[...]

The Software Clock, HZ, and Jiffies

The accuracy of many system calls and timestamps is limited by
the resolution of the software clock, a clock maintained by the
kernel which measures time in jiffies. The size of a
jiffy is determined by the value of the kernel constant HZ.

A related piece of information would be the 'clock correctness
principle' as forumlated in the NTP-documentation: Sucessive readings
of the clock must yield monotonically increasing values.

That is, after all, the purpose of a clock.
.



Relevant Pages

  • Re: after ids
    ... to do a better data structure for for almost ten years now, ... > It reports the user and system time ... kept the hardware clock set to local time, ... value, and the syscall will sleep until its end, regardless of any ...
    (comp.lang.tcl)
  • Re: Time problem
    ... Doing a bare "set time" seems to reset the clock to ... This clock keeps track of date and time in 24 hour binary ... The BB_WATCH time is used to initialize the running system time during ... The specification for maximum clock drift in the Alpha hardware clock ...
    (comp.os.vms)
  • Re: after ids
    ... implementattion. ... > It reports the user and system time ... Well, with a functioning NTP infrastructure, it's a non-issue. ... hardware clock is "rock solid" while system time is capricious, ...
    (comp.lang.tcl)
  • Re: [PATCH NET-NEXT 02/10] time sync: generic infrastructure to map between time stamps generate
    ... and transformation of hardware time stamps to system time. ... "assisted PTP" in the LCI PTP paper: ... I sort of object to the name clocksync, ... * Initialize to zero, then set clock, systime, num_samples. ...
    (Linux-Kernel)
  • Re: Linux 11-minute mode (RTC update)
    ... In my setup, STA_UNSYNC (0x0040, clock unsynchronized) is 0. ... Thus the kernel should write the system time to the RTC every ... Automatic Hardware Clock Synchronization By the Kernel ... by running anything, including hwclock --hctosys, that sets the System Time ...
    (Linux-Kernel)