Il 27/05/2014 16:54, Sebastian Tanase ha scritto:
The icount option already implemented in QEMU allows the guest to run at a
theoretical
frequency of 1/(2^N) GHz (N is the icount parameter). The goal of this patch is
to have a
real guest frequency close to the one imposed by using the icount option.
The main idea behind the algorithm is that we compare the virtual monotonic
clock and the
host monotonic clock. For big icounts (on our test machine, an i5 CPU @
3.10GHz, icounts
starting at 6) the guest clock will be ahead of the host clock. In this case,
we try to
sleep QEMU for the difference between the 2 clocks. Therefore, the guest would
have
executed for a period almost equally to the one imposed by icount. We should
point out
that the algorithm works only for those icounts that allow the guest clock to
be in front
of the host clock.
The first patch adds the 'align' parameter for icount and changes the icount
option from
'-icount [N|auto]' to '-icount [icount=][N|auto][,align]'.
The second patch exports 'icount_time_shift' so that it can be used in places
other than
cpus.c; we need it in cpu-exec.c for calculating for how long we want QEMU to
sleep.
The third patch implements the algorithm used for calculating the delay we want
to sleep.
It uses the number of instructions executed by the virtual cpu and also the
icount_time_shift.
The forth and final patch prints to the console whenever the guest clock runs
behind the host
clock. The fastest printing speed is every 2 seconds, and we only printif the
align option
is enabled.
It would be nice if you can move stuff out of cpu_exec and into separate
functions. But overall the code is solid. Thanks!
Paolo