Clement Deschamps
Builds for 1 pipeline passed in 5 minutes 40 seconds

qbox: fixed deadlock when cpus are sleeping

When all cpus are sleeping (e.g just entered WFE)
and SystemC is waiting because it is ahead of qemu,
it can lead to a deadlock where the main_loop is waiting.
The solution is to wake up the main_loop, so it then warp timers,
which makes qemu jump to the end of quantum and unlock SystemC.
Showing 1 changed file with 11 additions and 0 deletions
... ... @@ -1398,6 +1398,17 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg)
atomic_mb_set(&cpu->exit_request, 0);
}
/*
* When all cpus are sleeping (e.g just entered WFE)
* and SystemC is waiting because it is ahead of qemu,
* it can lead to a deadlock where the main_loop is waiting.
* The solution is to wake up the main_loop, so it then warp timers,
* which makes qemu jump to the end of quantum and unlock SystemC.
*/
if (all_cpu_threads_idle()) {
qemu_notify_event();
}
qemu_tcg_wait_io_event(cpu ? cpu : QTAILQ_FIRST(&cpus));
deal_with_unplugged_cpus();
}
... ...