mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-19 18:51:32 +00:00
new function qemu_icount_delta
Tweaking the rounding in qemu_next_deadline ensures that there's no change whatsoever. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
6325504302
commit
a2aaa079df
29
vl.c
29
vl.c
|
@ -548,6 +548,22 @@ static int64_t cpu_get_clock(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef CONFIG_IOTHREAD
|
||||||
|
static int64_t qemu_icount_delta(void)
|
||||||
|
{
|
||||||
|
if (!use_icount) {
|
||||||
|
return 5000 * (int64_t) 1000000;
|
||||||
|
} else if (use_icount == 1) {
|
||||||
|
/* When not using an adaptive execution frequency
|
||||||
|
we tend to get badly out of sync with real time,
|
||||||
|
so just delay for a reasonable amount of time. */
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return cpu_get_icount() - cpu_get_clock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* enable cpu_get_ticks() */
|
/* enable cpu_get_ticks() */
|
||||||
void cpu_enable_ticks(void)
|
void cpu_enable_ticks(void)
|
||||||
{
|
{
|
||||||
|
@ -4051,25 +4067,16 @@ static int qemu_calculate_timeout(void)
|
||||||
timeout = 5000;
|
timeout = 5000;
|
||||||
else if (tcg_has_work())
|
else if (tcg_has_work())
|
||||||
timeout = 0;
|
timeout = 0;
|
||||||
else if (!use_icount)
|
|
||||||
timeout = 5000;
|
|
||||||
else {
|
else {
|
||||||
/* XXX: use timeout computed from timers */
|
/* XXX: use timeout computed from timers */
|
||||||
int64_t add;
|
int64_t add;
|
||||||
int64_t delta;
|
int64_t delta;
|
||||||
/* Advance virtual time to the next event. */
|
/* Advance virtual time to the next event. */
|
||||||
if (use_icount == 1) {
|
delta = qemu_icount_delta();
|
||||||
/* When not using an adaptive execution frequency
|
|
||||||
we tend to get badly out of sync with real time,
|
|
||||||
so just delay for a reasonable amount of time. */
|
|
||||||
delta = 0;
|
|
||||||
} else {
|
|
||||||
delta = cpu_get_icount() - cpu_get_clock();
|
|
||||||
}
|
|
||||||
if (delta > 0) {
|
if (delta > 0) {
|
||||||
/* If virtual time is ahead of real time then just
|
/* If virtual time is ahead of real time then just
|
||||||
wait for IO. */
|
wait for IO. */
|
||||||
timeout = (delta / 1000000) + 1;
|
timeout = (delta + 999999) / 1000000;
|
||||||
} else {
|
} else {
|
||||||
/* Wait for either IO to occur or the next
|
/* Wait for either IO to occur or the next
|
||||||
timer event. */
|
timer event. */
|
||||||
|
|
Loading…
Reference in a new issue