[ntp:questions] Re: NTP and Cron

David Woolley david at djwhome.demon.co.uk
Wed Dec 1 07:55:41 UTC 2004

In article <3a2a0492.0411301454.e48c55f at posting.google.com>,
mayer at gis.net (Danny Mayer) wrote:

> ntp never decrements the time. If it's necessary it will reduce the
> adjustments. Remember that time is monotonically increasing.

That's not true.  At one time I think there may have been an option to
produce that behaviour, and some vendors may have hacked in this behaviour,
but this is the code in 4.2.0 that decides whether to start the 900s 
qualification period for initiating a step.  Note that it takes the
absolute value of the offset:

        if (fabs(fp_offset) > clock_max && clock_max > 0) {
                switch (state) {

and this is the part of the code with the machine independent logic for
calculating the stepped time.  Note the symmetry between positive and
negative cases:

        if (isneg) {
                timetv.tv_sec -= adjtv.tv_sec;
                timetv.tv_usec -= adjtv.tv_usec;
                if (timetv.tv_usec < 0) {
                        timetv.tv_usec += 1000000;
        } else {
                timetv.tv_sec += adjtv.tv_sec;
                timetv.tv_usec += adjtv.tv_usec;
                if (timetv.tv_usec >= 1000000) {
                        timetv.tv_usec -= 1000000;

More information about the questions mailing list