qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Application of QEMUTimer in short timing.


From: Peter Maydell
Subject: Re: Application of QEMUTimer in short timing.
Date: Tue, 7 Sep 2021 13:19:45 +0100

On Tue, 7 Sept 2021 at 12:28, Duo jia <jiaduo19920301@gmail.com> wrote:
>
> In the controller, QEMUTimer will be used in the implementation of timer 
> simulation.
>
> I wrote an auto-loading timer with a period of 1ms and the clock source used 
> is QEMU_CLOCK_VIRTUAL. But it doesn't seem to be very accurate, because the 
> actual time after I accumulated it to 500 times took about 700ms.

It depends on how you use it. Generally the actual firing will not happen
exactly on the specified mark. So if your implementation is "set clock
for 1ms in the future; when it fires, set for 1ms in the future again"
that is likely to be inaccurate. If you implement it as "set clock for
1ms in the future; when it fires, set for 1ms after the time when it
should have fired" it will probably be better.

In particular, if the semantics of your timer fit the ptimer API
(which can implement oneshot and periodic timers) then I would recommend
using that instead of a raw QEMUTimer; it deals with a lot of these
fiddly details for you.

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]