really fix -icount in the iothread case
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 13 Apr 2011 08:03:43 +0000 (10:03 +0200)
committerEdgar E. Iglesias <edgar.iglesias@gmail.com>
Fri, 15 Apr 2011 07:27:56 +0000 (09:27 +0200)
commitbd0c054d31f062b3cb950800e2d9bdba2d17a663
tree206e5221bc65ea69cf03e60f72a006bef55f0cae
parent62643f7b04965e20e4538ad5e0bf260d6b54cda6
really fix -icount in the iothread case

The correct fix for -icount is to consider the biggest difference
between iothread and non-iothread modes.  In the traditional model,
CPUs run _before_ the iothread calls select (or WaitForMultipleObjects
for Win32).  In the iothread model, CPUs run while the iothread
isn't holding the mutex, i.e. _during_ those same calls.

So, the iothread should always block as long as possible to let
the CPUs run smoothly---the timeout might as well be infinite---and
either the OS or the CPU thread itself will let the iothread know
when something happens.  At this point, the iothread wakes up and
interrupts the CPU.

This is exactly the approach that this patch takes: when cpu_exec_all
returns in -icount mode, and it is because a vm_clock deadline has
been met, it wakes up the iothread to process the timers.  This is
really the "bulk" of fixing icount.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
cpus.c