I have a related but different question.
I am reading the time with QDateTime::currentMSecsSinceEpoch(). How
susceptible is this time to clock drift/jitter/etc. on Linux (Kubuntu
16.04.2)? I know ntpd is constantly updating the time, and there is some
error involved in this. If I am reading the time from
QDateTime::currentMSecsSinceEpoch() and using it to set a QTimer every
40ms, how does ntpd constantly correcting the time going to affect this,
if at all?
FYI: My timer slot basically looks like this:
void myClass::animationTimerSlot(void)
{
if(firstTime)
startTime=QDateTime::currentMSecsSinceEpoch();
dowork();
frameCnt++;
int t = startTime + ((double)frameCnt*40.0) -
QDateTime::currentMSecsSinceEpoch();
if(t<0)
t=0;
animTimer->start(t);
}
Thanks!
Josh
On Wed, 26 Jul 2017, Thiago Macieira wrote:
On quarta-feira, 26 de julho de 2017 14:23:29 PDT Joshua Grauman wrote:
Thanks so much for the response.
So do I have this right then?
QTimer doesn't use any actually timers in the OS (no system
calls/interrupts). It is all handled internally by Qt's event loop. So if
the OS doesn't give Qt CPU time, it will miss a timer. Calling 'nice'
(Linux) on the process may help with this.
On Windows, it will use multimedia timers (timerSetEvent()) for precise
timers, SetTimer() for the others. How the OS services those, I don't have a
clue.[*]
I have a pending patch to make it use CLOCK_MONOTONIC_COARSE on Linux (and
CLOCK_MONOTONIC_FAST on BSDs), but I've run into some problems that some
timers wake up in the wrong order. The coarse and precise timers are not
sync'ed in the OS: even if you query the latter, the former may not update, so
it may look like the monotonic clock went backwards.
Until then, everything uses the same clock on Unix and simply depends on when
the OS wakes us up from ppoll().
[*] I have a vague memory of the regular timers having a 4 ms granularity.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest