|From:||Nguyen Anh Quynh|
|Subject:||Re: [Qemu-devel] How Qemu timer interrupts code emulation?|
|Date:||Sat, 23 May 2015 00:26:55 +0800|
On 22 May 2015 at 16:36, Jun Koi <address@hidden> 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.
|[Prev in Thread]||Current Thread||[Next in Thread]|