All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Duo jia <jiaduo19920301@gmail.com>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: Application of QEMUTimer in short timing.
Date: Tue, 7 Sep 2021 13:19:45 +0100	[thread overview]
Message-ID: <CAFEAcA-H_titydNAYO94k4i5uiJyTXXt=tNyPd7RfjFMjRYb1w@mail.gmail.com> (raw)
In-Reply-To: <CALUzjTbw0m-n0wmqYPw9C_SFVrCYvqOde6qUsB40FMM9BVPHZg@mail.gmail.com>

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	other threads:[~2021-09-07 12:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-07 11:26 Application of QEMUTimer in short timing Duo jia
2021-09-07 12:19 ` Peter Maydell [this message]
2021-09-08  2:50   ` Duo jia
2021-09-08  9:46     ` Peter Maydell
2021-09-09 12:21       ` Duo jia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFEAcA-H_titydNAYO94k4i5uiJyTXXt=tNyPd7RfjFMjRYb1w@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=jiaduo19920301@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.