[Top][All Lists]

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

Re: [Qemu-devel] How to break cpu_tb_exec()?

From: Jun Koi
Subject: Re: [Qemu-devel] How to break cpu_tb_exec()?
Date: Sat, 4 Jul 2015 01:24:15 +0800

On Sat, Jul 4, 2015 at 1:12 AM, Peter Maydell <address@hidden> wrote:
On 3 July 2015 at 18:10, Jun Koi <address@hidden> wrote:
> On Sat, Jul 4, 2015 at 1:06 AM, Peter Maydell <address@hidden>
> wrote:
>> On 3 July 2015 at 18:02, Jun Koi <address@hidden> wrote:
>> > If this is true, then what if this TB is running infinitely, and do not
>> > return, or it is in a very long loop? In this case, TCG thread cannot be
>> > interrupted?
>> Every TB starts with a little bit of generated code that checks
>> the 'tcg_exit_req' flag in the CPUState for the CPU (see the
>> gen_tb_start() function). If some other part of QEMU wants the
>> CPU to stop running guest code and return to the top level loop,
>> it calls cpu_exit() which sets this flag.
> But this does not answer my question yet: if we the flag is only
> enable when TB already enters the "long loop", then nothing can break
> this TB execution?

We check the flag for every TB we execute. Therefore in any
loop we must check the flag each time round the loop. So
if another thread sets the flag, we will exit.

(A TB is always ended by any kind of branch instruction,
so you can't have a loop within a single TB. A tight loop
turns into a TB that ends with "branch back to the start
of this TB", but that will re-execute the flag-check code.)

Oh right, this tight loop is my main concern. It makes sense now.


reply via email to

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