#include "qemu/notify.h"
#include "qemu/guest-random.h"
#include "exec/exec-all.h"
-#include "tcg/tcg.h"
+#include "tcg/startup.h"
#include "tcg-accel-ops.h"
#include "tcg-accel-ops-rr.h"
#include "tcg-accel-ops-icount.h"
{
CPUState *cpu;
- while (all_cpu_threads_idle()) {
+ while (all_cpu_threads_idle() && replay_can_wait()) {
rr_stop_kick_timer();
- qemu_cond_wait_iothread(first_cpu->halt_cond);
+ qemu_cond_wait_bql(first_cpu->halt_cond);
}
rr_start_kick_timer();
CPU_FOREACH(cpu) {
if (cpu->unplug && !cpu_can_run(cpu)) {
- tcg_cpus_destroy(cpu);
+ tcg_cpu_destroy(cpu);
break;
}
}
rcu_add_force_rcu_notifier(&force_rcu);
tcg_register_thread();
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_thread_get_self(cpu->thread);
cpu->thread_id = qemu_get_thread_id();
- cpu->can_do_io = 1;
+ cpu->neg.can_do_io = true;
cpu_thread_signal_created(cpu);
qemu_guest_random_seed_thread_part2(cpu->random_seed);
/* wait for initial kick-off after machine start */
while (first_cpu->stopped) {
- qemu_cond_wait_iothread(first_cpu->halt_cond);
+ qemu_cond_wait_bql(first_cpu->halt_cond);
/* process any pending work */
CPU_FOREACH(cpu) {
/* Only used for icount_enabled() */
int64_t cpu_budget = 0;
- qemu_mutex_unlock_iothread();
+ bql_unlock();
replay_mutex_lock();
- qemu_mutex_lock_iothread();
+ bql_lock();
if (icount_enabled()) {
int cpu_count = rr_cpu_count();
if (cpu_can_run(cpu)) {
int r;
- qemu_mutex_unlock_iothread();
+ bql_unlock();
if (icount_enabled()) {
icount_prepare_for_run(cpu, cpu_budget);
}
if (icount_enabled()) {
icount_process_data(cpu);
}
- qemu_mutex_lock_iothread();
+ bql_lock();
if (r == EXCP_DEBUG) {
cpu_handle_guest_debug(cpu);
break;
} else if (r == EXCP_ATOMIC) {
- qemu_mutex_unlock_iothread();
+ bql_unlock();
cpu_exec_step_atomic(cpu);
- qemu_mutex_lock_iothread();
+ bql_lock();
break;
}
} else if (cpu->stop) {
single_tcg_halt_cond = cpu->halt_cond;
single_tcg_cpu_thread = cpu->thread;
-#ifdef _WIN32
- cpu->hThread = qemu_thread_get_handle(cpu->thread);
-#endif
} else {
/* we share the thread */
cpu->thread = single_tcg_cpu_thread;
cpu->halt_cond = single_tcg_halt_cond;
cpu->thread_id = first_cpu->thread_id;
- cpu->can_do_io = 1;
+ cpu->neg.can_do_io = 1;
cpu->created = true;
}
}