Revision 16400322
b/cpus.c | ||
---|---|---|
137 | 137 |
return 1; |
138 | 138 |
} |
139 | 139 |
|
140 |
static int cpu_has_work(CPUState *env)
|
|
140 |
static bool cpu_thread_is_idle(CPUState *env)
|
|
141 | 141 |
{ |
142 |
if (env->stop) |
|
143 |
return 1; |
|
144 |
if (env->queued_work_first) |
|
145 |
return 1; |
|
146 |
if (env->stopped || !vm_running) |
|
147 |
return 0; |
|
148 |
if (!env->halted) |
|
149 |
return 1; |
|
150 |
if (qemu_cpu_has_work(env)) |
|
151 |
return 1; |
|
152 |
return 0; |
|
142 |
if (env->stop || env->queued_work_first) { |
|
143 |
return false; |
|
144 |
} |
|
145 |
if (env->stopped || !vm_running) { |
|
146 |
return true; |
|
147 |
} |
|
148 |
if (!env->halted || qemu_cpu_has_work(env)) { |
|
149 |
return false; |
|
150 |
} |
|
151 |
return true; |
|
153 | 152 |
} |
154 | 153 |
|
155 |
static int any_cpu_has_work(void)
|
|
154 |
static bool all_cpu_threads_idle(void)
|
|
156 | 155 |
{ |
157 | 156 |
CPUState *env; |
158 | 157 |
|
159 |
for (env = first_cpu; env != NULL; env = env->next_cpu) |
|
160 |
if (cpu_has_work(env)) |
|
161 |
return 1; |
|
162 |
return 0; |
|
158 |
for (env = first_cpu; env != NULL; env = env->next_cpu) { |
|
159 |
if (!cpu_thread_is_idle(env)) { |
|
160 |
return false; |
|
161 |
} |
|
162 |
} |
|
163 |
return true; |
|
163 | 164 |
} |
164 | 165 |
|
165 | 166 |
static void cpu_debug_handler(CPUState *env) |
... | ... | |
743 | 744 |
{ |
744 | 745 |
CPUState *env; |
745 | 746 |
|
746 |
while (!any_cpu_has_work())
|
|
747 |
while (all_cpu_threads_idle()) {
|
|
747 | 748 |
qemu_cond_timedwait(tcg_halt_cond, &qemu_global_mutex, 1000); |
749 |
} |
|
748 | 750 |
|
749 | 751 |
qemu_mutex_unlock(&qemu_global_mutex); |
750 | 752 |
|
... | ... | |
765 | 767 |
|
766 | 768 |
static void qemu_kvm_wait_io_event(CPUState *env) |
767 | 769 |
{ |
768 |
while (!cpu_has_work(env))
|
|
770 |
while (cpu_thread_is_idle(env)) {
|
|
769 | 771 |
qemu_cond_timedwait(env->halt_cond, &qemu_global_mutex, 1000); |
772 |
} |
|
770 | 773 |
|
771 | 774 |
qemu_kvm_eat_signals(env); |
772 | 775 |
qemu_wait_io_event_common(env); |
... | ... | |
1070 | 1073 |
} |
1071 | 1074 |
} |
1072 | 1075 |
exit_request = 0; |
1073 |
return any_cpu_has_work();
|
|
1076 |
return !all_cpu_threads_idle();
|
|
1074 | 1077 |
} |
1075 | 1078 |
|
1076 | 1079 |
void set_numa_modes(void) |
Also available in: Unified diff