[Lazarus] Better implementation of GetTickcount using clock_gettime

zeljko zeljko at holobit.net
Wed Apr 2 15:12:09 CEST 2014


On 04/02/2014 02:28 PM, Mattias Gaertner wrote:
> On Wed, 02 Apr 2014 14:01:26 +0200
> zeljko <zeljko at holobit.net> wrote:
>
>> [...]
>> My guess is that there no need to speculate what most programs need but
>> what is more precise or better to say what is correct.
>
> They measure different things. The precision depends on what you
> expect.
>
>
>> IMO CLOCK_MONOTONIC is affected by eg. ntp/adjtime() so result of
>> GetTickCount() is not correct in all cases.
>> Imagine daemon service which relies on GetTickCount and then clock
>> change due to the daylight via
>
> Sigh. Again: CLOCK_MONOTONIC is monotonic. It does not go
> backwards and especially it does not apply timezone, daylight or user
> time changes. It only fixes shortcomings of the machine counters.
>
> See for example here:
> http://man7.org/linux/man-pages/man2/clock_gettime.2.html

Do we read same man page ?

CLOCK_MONOTONIC
               Clock that cannot be set and represents monotonic time
               since some unspecified starting point.  This clock is
               not affected by discontinuous jumps in the system time
               (e.g., if the system administrator manually changes the
               clock), *but is affected by the incremental adjustments
               performed by adjtime(3) and NTP*.

CLOCK_MONOTONIC_RAW (since Linux 2.6.28; Linux-specific)
               Similar to CLOCK_MONOTONIC, but provides access to a
               raw hardware-based time that *is not subject to NTP
               adjustments or the incremental adjustments performed by
               adjtime(3)*.

zeljko








More information about the Lazarus mailing list