Recent

Author Topic: Timer difference in Linux and Windows  (Read 441 times)

ortegahernandes

  • New Member
  • *
  • Posts: 20
Timer difference in Linux and Windows
« on: January 23, 2025, 04:42:56 pm »
When I do a simple count within the Lazarus timer function on Windows and Linux, if the timer is defined with low values ​​ex 2 ms, there is a large discrepancy in values ​​between the operating system.

Is this normal?


marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12035
  • FPC developer.
Re: Timer difference in Linux and Windows
« Reply #1 on: January 23, 2025, 04:47:20 pm »
Yes

DragoRosso

  • New Member
  • *
  • Posts: 46
Re: Timer difference in Linux and Windows
« Reply #2 on: January 23, 2025, 05:55:43 pm »
In windows the normal timing resolution is 1 ms. (or less in the new hardware) but the consistency is near 16 ms. This means that when you have a timing or sleep or others look at step of 16 ms.

The events should be between less than value that you imposed and near 16 / 17 ms.

In Linux I don't know.

Example: if you set the timer to 10 ms. the events may signals between 8 to 17 ms. (this is an example, every time you do this the timing is different).

You can use a SysInternals Util https://learn.microsoft.com/it-it/sysinternals/downloads/clockres to view your config in Windows.

Quote
Clockres v2.1 - Clock resolution display utility
Copyright (C) 2016 Mark Russinovich
Sysinternals

Maximum timer interval: 15.625 ms
Minimum timer interval: 0.500 ms
Current timer interval: 1.000 ms

You can change the "maximun interval" using MMSystem, with timebeginperiod(1) and timeendperiod(1) functions ... see Microsoft documention CAREFULLY: https://learn.microsoft.com/en-us/windows/win32/api/timeapi/nf-timeapi-timebeginperiod
« Last Edit: January 23, 2025, 05:57:26 pm by DragoRosso »

Thaddy

  • Hero Member
  • *****
  • Posts: 16520
  • Kallstadt seems a good place to evict Trump to.
Re: Timer difference in Linux and Windows
« Reply #3 on: January 23, 2025, 06:51:31 pm »
Yes
https://en.wikipedia.org/wiki/Schr%C3%B6dinger%27s_cat
Not everyone has the luxury of a degree ( or two ) from a proper one.
But I am sure they don't want the Trumps back...

 

TinyPortal © 2005-2018