提交 b99dc0d1 编写于 作者: B balrog

Redundant timer rearm optimisation by Anders Melchiorsen.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3823 c046a42c-6fe2-441c-8c8c-71466251a162
上级 b01bcae6
......@@ -822,6 +822,7 @@ struct qemu_alarm_timer {
};
#define ALARM_FLAG_DYNTICKS 0x1
#define ALARM_FLAG_MODIFIED 0x2
static inline int alarm_has_dynticks(struct qemu_alarm_timer *t)
{
......@@ -833,6 +834,11 @@ static void qemu_rearm_alarm_timer(struct qemu_alarm_timer *t)
if (!alarm_has_dynticks(t))
return;
if (!(t->flags & ALARM_FLAG_MODIFIED))
return;
t->flags &= ~(ALARM_FLAG_MODIFIED);
t->rearm(t);
}
......@@ -995,6 +1001,8 @@ void qemu_del_timer(QEMUTimer *ts)
{
QEMUTimer **pt, *t;
alarm_timer->flags |= ALARM_FLAG_MODIFIED;
/* NOTE: this code must be signal safe because
qemu_timer_expired() can be called from a signal. */
pt = &active_timers[ts->clock->type];
......@@ -1067,7 +1075,6 @@ static void qemu_run_timers(QEMUTimer **ptimer_head, int64_t current_time)
/* run the callback (the timer list can be modified) */
ts->cb(ts->opaque);
}
qemu_rearm_alarm_timer(alarm_timer);
}
int64_t qemu_get_clock(QEMUClock *clock)
......@@ -1187,6 +1194,7 @@ static void host_alarm_handler(int host_signum)
CPUState *env = next_cpu;
if (env) {
alarm_timer->flags |= ALARM_FLAG_MODIFIED;
/* stop the currently executing cpu because a timer occured */
cpu_interrupt(env, CPU_INTERRUPT_EXIT);
#ifdef USE_KQEMU
......@@ -7364,6 +7372,8 @@ void main_loop_wait(int timeout)
qemu_run_timers(&active_timers[QEMU_TIMER_REALTIME],
qemu_get_clock(rt_clock));
qemu_rearm_alarm_timer(alarm_timer);
/* Check bottom-halves last in case any of the earlier events triggered
them. */
qemu_bh_poll();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册