bool cpu_exec_all (void) { static int i = 0; if (next_cpu == NULL) { next_cpu = first_cpu; i = 0; } for (; next_cpu != NULL && !exit_request; next_cpu = next_cpu->next_cpu, i++) { CPUState *env = next_cpu; rr_run = env->kvm_run; cpu_number = i; qemu_clock_enable(vm_clock, (env->singlestep_enabled & SSTEP_NOTIMER) == 0); if (qemu_alarm_pending()) break; if (cpu_can_run(env)) { if (qemu_cpu_exec(env) == EXCP_DEBUG) { break; } } else if (env->stop) { break; } } exit_request = 0; return any_cpu_has_work(); }
bool cpu_exec_all(void) { if (next_cpu == NULL) next_cpu = first_cpu; for (; next_cpu != NULL && !exit_request; next_cpu = next_cpu->next_cpu) { CPUState *env = next_cpu; qemu_clock_enable(vm_clock, (env->singlestep_enabled & SSTEP_NOTIMER) == 0); if (qemu_alarm_pending()) break; if (cpu_can_run(env)) { if (qemu_cpu_exec(env) == EXCP_DEBUG) { break; } } else if (env->stop) { #ifdef MARSS_QEMU continue; /* Let other CPUS execute */ #else break; #endif } #ifdef MARSS_QEMU if (in_simulation) /* No need to run for other cpus */ break; #endif } #ifdef MARSS_QEMU if (!any_cpu_has_work()) { /* All CPUs are paused, call ptl_simpoint reached * to check if we need to switch to simulation or not */ ptl_simpoint_reached(0); } #endif exit_request = 0; return any_cpu_has_work(); }
static void qemu_tcg_wait_io_event(void) { CPUState *env; while (!any_cpu_has_work()) qemu_cond_timedwait(tcg_halt_cond, &qemu_global_mutex, 1000); qemu_mutex_unlock(&qemu_global_mutex); /* * Users of qemu_global_mutex can be starved, having no chance * to acquire it since this path will get to it first. * So use another lock to provide fairness. */ qemu_mutex_lock(&qemu_fair_mutex); qemu_mutex_unlock(&qemu_fair_mutex); qemu_mutex_lock(&qemu_global_mutex); for (env = first_cpu; env != NULL; env = env->next_cpu) { qemu_wait_io_event_common(env); } }