PDA

View Full Version : Accuracy of the timer in Qt



Fastman
19th July 2009, 19:41
What better way to recommend the following tasks:
There is a time event (HH: MM: SS: MS).
It is necessary at this time, follow the steps.
The accuracy should not affect validity of GUI.

wysota
19th July 2009, 22:04
The accuracy of timers depends on the operating system. In general you will never have assurance that the call will be made exactly at the time specified. You can get very close to that value if you are using a real-time operating system but you can forget about it on regular Linux or Windows installations. Also note that Windows has a lower timer resolution that other systems (I don't know if you can tweak it).

Fastman
19th July 2009, 22:50
But if I set timer in a separate thread, and will catch the system time ... for example.. every 40ms then I will be able to get accuracy +/- 40ms ?

Lykurg
19th July 2009, 22:59
But if I set timer in a separate thread, and will catch the system time ... for example.. every 40ms then I will be able to get accuracy +/- 40ms ?
no, because also your thread can be blocked for lets say 2 seconds, and then you don't have a accuracy of 40ms. (And beside, I think QTimer uses a separate thread by itself)((and this solution is lesser accurate than simple use a QTimer direkt.))

If you need a 100% accuracy you have to use a RTOS (http://en.wikipedia.org/wiki/Real-time_operating_system).

Anyway, is your application really so time sensible?

Fastman
21st July 2009, 17:01
no, because also your thread can be blocked for lets say 2 seconds, and then you don't have a accuracy of 40ms. (And beside, I think QTimer uses a separate thread by itself)((and this solution is lesser accurate than simple use a QTimer direkt.))

If you need a 100% accuracy you have to use a RTOS (http://en.wikipedia.org/wiki/Real-time_operating_system).

Anyway, is your application really so time sensible?

thх for help.

Yes .. the fact that is often required to surrender to the television control signal with an accuracy of 2-5 frames. If you are using a frame rate 25 .. then each frame is 40ms...

wysota
21st July 2009, 21:52
As far as I remember you can't get a better resolution that 50ms on some Windows systems, so aim for that. If your system doesn't do anything besides handling your application, it will do fine.