Core Timing: Rework Core Timing to run all cores evenly.

This commit is contained in:
Fernando Sahmkow 2019-09-09 21:37:29 -04:00 committed by FernandoS27
parent e664c24355
commit 555866f8dc
6 changed files with 89 additions and 38 deletions

View file

@ -6,6 +6,7 @@
#include "core/arm/exclusive_monitor.h"
#include "core/core.h"
#include "core/core_cpu.h"
#include "core/core_timing.h"
#include "core/cpu_core_manager.h"
#include "core/gdbstub/gdbstub.h"
#include "core/settings.h"
@ -122,13 +123,19 @@ void CpuCoreManager::RunLoop(bool tight_loop) {
}
}
for (active_core = 0; active_core < NUM_CPU_CORES; ++active_core) {
cores[active_core]->RunLoop(tight_loop);
if (Settings::values.use_multi_core) {
// Cores 1-3 are run on other threads in this mode
break;
auto& core_timing = system.CoreTiming();
core_timing.ResetRun();
bool keep_running{};
do {
keep_running = false;
for (active_core = 0; active_core < NUM_CPU_CORES; ++active_core) {
core_timing.SwitchContext(active_core);
if (core_timing.CurrentContextCanRun()) {
cores[active_core]->RunLoop(tight_loop);
}
keep_running |= core_timing.CurrentContextCanRun();
}
}
} while (keep_running);
if (GDBStub::IsServerEnabled()) {
GDBStub::SetCpuStepFlag(false);