static QemuMutex qemu_global_mutex;
static QemuCond qemu_io_proceeded_cond;
-static bool iothread_requesting_mutex;
+static unsigned iothread_requesting_mutex;
static QemuThread io_thread;
void qemu_mutex_lock_iothread(void)
{
- if (!tcg_enabled()) {
+ if (!tcg_enabled() || !first_cpu) {
qemu_mutex_lock(&qemu_global_mutex);
} else {
- iothread_requesting_mutex = true;
+ atomic_inc(&iothread_requesting_mutex);
if (qemu_mutex_trylock(&qemu_global_mutex)) {
qemu_cpu_kick_thread(first_cpu);
qemu_mutex_lock(&qemu_global_mutex);
}
- iothread_requesting_mutex = false;
+ atomic_dec(&iothread_requesting_mutex);
qemu_cond_broadcast(&qemu_io_proceeded_cond);
}
}