[Libav-user] Best way to create a fractional ms timer?

"René J.V. Bertin" rjvbertin at gmail.com
Mon Apr 1 14:59:32 CEST 2013


On Apr 01, 2013, at 12:07, Nicolas George wrote:

>> original post, but I've already struggled myself to get reliable 1kHz
>> realtime behaviour without external hardware. I ended up with a busy-wait
>> loop, (hogging the CPU was acceptable in my case).
> 
> Basic sanity check: I hope everyone here realizes that on a non-real time
> OS, even a timer with that kind of nominal precision can end up waiting a
> few dozens milliseconds because the screen saver activated or a page was
> needed from the swap? Modern hardware, with multicore CPUs and loads of
> memory, make this less severe a problem, but you still get no guarantee at
> all.
> 

Of course, presuming your remark concerned the last bit of my post.

I may be mistaken, but I think that the higher your timer precision, the lower the jitter such 'force-majeur' events produce (or, the jitter is proportional to your timer's precision). Right?

@Mike : 1ms will be very unreliable in what scenario? Using an MS timer? My experience would agree with that...

Just as an anecdote: I worked in a driving simulation laboratory until about a year ago. They use a software base that used to run on SGI workstations, then under Linux, and nowadays under MS Windows (because of graphics driver support). The last versions I've seen run under WinXP had an infrequent issue where the visual would sometimes freeze for a second or 2. This was visible, EXCEPT in the logs, as if time had stood still during those lapses. And indeed, switching to "real time" priority would preempt the machine to a large extent, but not improve timing regularity by that much.

R




More information about the Libav-user mailing list