Revision c9f7383c
b/qemu-timer.c | ||
---|---|---|
112 | 112 |
|
113 | 113 |
static int64_t qemu_icount_delta(void) |
114 | 114 |
{ |
115 |
if (!use_icount) { |
|
116 |
return 5000 * (int64_t) 1000000; |
|
117 |
} else if (use_icount == 1) { |
|
115 |
if (use_icount == 1) { |
|
118 | 116 |
/* When not using an adaptive execution frequency |
119 | 117 |
we tend to get badly out of sync with real time, |
120 | 118 |
so just delay for a reasonable amount of time. */ |
... | ... | |
1077 | 1075 |
int qemu_calculate_timeout(void) |
1078 | 1076 |
{ |
1079 | 1077 |
int timeout; |
1078 |
int64_t add; |
|
1079 |
int64_t delta; |
|
1080 | 1080 |
|
1081 |
#ifdef CONFIG_IOTHREAD |
|
1082 | 1081 |
/* When using icount, making forward progress with qemu_icount when the |
1083 | 1082 |
guest CPU is idle is critical. We only use the static io-thread timeout |
1084 | 1083 |
for non icount runs. */ |
1085 |
if (!use_icount) { |
|
1086 |
return 1000;
|
|
1084 |
if (!use_icount || !vm_running) {
|
|
1085 |
return 5000;
|
|
1087 | 1086 |
} |
1088 |
#endif |
|
1089 | 1087 |
|
1090 |
if (!vm_running) |
|
1091 |
timeout = 5000; |
|
1092 |
else { |
|
1093 |
/* XXX: use timeout computed from timers */ |
|
1094 |
int64_t add; |
|
1095 |
int64_t delta; |
|
1096 |
/* Advance virtual time to the next event. */ |
|
1097 |
delta = qemu_icount_delta(); |
|
1098 |
if (delta > 0) { |
|
1099 |
/* If virtual time is ahead of real time then just |
|
1100 |
wait for IO. */ |
|
1101 |
timeout = (delta + 999999) / 1000000; |
|
1102 |
} else { |
|
1103 |
/* Wait for either IO to occur or the next |
|
1104 |
timer event. */ |
|
1105 |
add = qemu_next_deadline(); |
|
1106 |
/* We advance the timer before checking for IO. |
|
1107 |
Limit the amount we advance so that early IO |
|
1108 |
activity won't get the guest too far ahead. */ |
|
1109 |
if (add > 10000000) |
|
1110 |
add = 10000000; |
|
1111 |
delta += add; |
|
1112 |
qemu_icount += qemu_icount_round (add); |
|
1113 |
timeout = delta / 1000000; |
|
1114 |
if (timeout < 0) |
|
1115 |
timeout = 0; |
|
1116 |
} |
|
1088 |
/* Advance virtual time to the next event. */ |
|
1089 |
delta = qemu_icount_delta(); |
|
1090 |
if (delta > 0) { |
|
1091 |
/* If virtual time is ahead of real time then just |
|
1092 |
wait for IO. */ |
|
1093 |
timeout = (delta + 999999) / 1000000; |
|
1094 |
} else { |
|
1095 |
/* Wait for either IO to occur or the next |
|
1096 |
timer event. */ |
|
1097 |
add = qemu_next_deadline(); |
|
1098 |
/* We advance the timer before checking for IO. |
|
1099 |
Limit the amount we advance so that early IO |
|
1100 |
activity won't get the guest too far ahead. */ |
|
1101 |
if (add > 10000000) |
|
1102 |
add = 10000000; |
|
1103 |
delta += add; |
|
1104 |
qemu_icount += qemu_icount_round (add); |
|
1105 |
timeout = delta / 1000000; |
|
1106 |
if (timeout < 0) |
|
1107 |
timeout = 0; |
|
1117 | 1108 |
} |
1118 | 1109 |
|
1119 | 1110 |
return timeout; |
Also available in: Unified diff