From: Peter Maydell <peter.maydell@linaro.org>
To: Jun Koi <junkoi2004@gmail.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] How Qemu timer interrupts code emulation?
Date: Fri, 22 May 2015 17:13:09 +0100 [thread overview]
Message-ID: <CAFEAcA_R1FJy8mJTSsrFDBXgDb4LXA71nnr-QAMQwWe17hMXMw@mail.gmail.com> (raw)
In-Reply-To: <CA+g7VZ28xuRYXfTaw=EwgpSwAAC3btqyn9XWwkWwqicqONxq7g@mail.gmail.com>
On 22 May 2015 at 16:36, Jun Koi <junkoi2004@gmail.com> wrote:
> In general, we would have timer & code execution run in parallel,
No code has to actually run when there's an active timer;
the event loop thread mostly sits blocked waiting for
something interesting to happen (io or a timer firing).
When it does then the event loop thread will call the
generic timer code, which will call the callback function
for that timer. Typically this is inside the device model
for whatever timer the hardware you're modelling is. It
will then (assuming it really wants to create a simulated
interrupt) call qemu_irq_set() to set its outbound IRQ
line. This will then end up calling into the emulated
interrupt controller and eventually (if the irq is not
masked by the interrupt controller) into the emulated
CPU, which calls cpu_interrupt(). In TCG that ends up
calling tcg_handle_interrupt(), which sets cpu->tcg_exit_req.
Every block of translated code has an initial part
(written by gen_tb_start()) which checks this flag, and
returns to the TCG main loop (in cpu-exec.c) if it is set.
Every time round the TCG main loop we check if there are
any pending interrupts, and if so we call the appropriate
CPU function to emulate the "take an interrupt" behaviour
of the target CPU.
-- PMM
next prev parent reply other threads:[~2015-05-22 16:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-22 15:36 [Qemu-devel] How Qemu timer interrupts code emulation? Jun Koi
2015-05-22 16:13 ` Peter Maydell [this message]
2015-05-22 16:26 ` Nguyen Anh Quynh
2015-05-22 23:03 ` Bastian Koppelmann
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_R1FJy8mJTSsrFDBXgDb4LXA71nnr-QAMQwWe17hMXMw@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=junkoi2004@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).