[Lazarus] Better implementation of GetTickcount using clock_gettime

Anton Kavalenka anton.k at tut.by
Wed Apr 2 12:45:08 CEST 2014


On 02.04.2014 11:53, zeljko wrote:
> On 04/02/2014 10:01 AM, Mattias Gaertner wrote:
>> On Wed, 02 Apr 2014 09:47:45 +0200
>> Luca Olivetti <luca at wetron.es> wrote:
>>
>>> [...]
>>> Btw, in theory CLOCK_MONOTONIC_RAW should be even better, though it's
>>> only available from linux 2.6.28
>>
>> CLOCK_MONOTONIC_RAW lacks the fixes by NTP.
>
> That's not good for Now(), but it's perfect solution for getTickCount().
> GetTickCount() should not be aware of ntp or adjtime() changes - so in 
> that case CLOCK_MONOTONIC_RAW is the only correct solution.
>
> z.
>

Yes - CLOCK_MONOTONICC_RAW is prefreable, because general GetTickCount() 
is number of millisecond ticks since system startup. It cannot be 
adjusted by time services, it just grows up every 1 msec.
Ant typical GetTickCount() usage - find a difference between subsequent 
values.
It would be amazing when difference gets negative.

regards,
Anton




More information about the Lazarus mailing list