From 555866f8dcb98897688d5d7b0e6c6cca55ac069f Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Mon, 9 Sep 2019 21:37:29 -0400 Subject: Core Timing: Rework Core Timing to run all cores evenly. --- src/core/cpu_core_manager.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/core/cpu_core_manager.cpp') diff --git a/src/core/cpu_core_manager.cpp b/src/core/cpu_core_manager.cpp index 8fcb4eeb1..e022e6a60 100644 --- a/src/core/cpu_core_manager.cpp +++ b/src/core/cpu_core_manager.cpp @@ -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); -- cgit v1.2.3 From e0650a2034026d8292196128d2f9decb50eeb0f3 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Fri, 11 Oct 2019 14:44:14 -0400 Subject: Core_Timing: Address Feedback and suppress warnings. --- src/core/cpu_core_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core/cpu_core_manager.cpp') diff --git a/src/core/cpu_core_manager.cpp b/src/core/cpu_core_manager.cpp index e022e6a60..16b384076 100644 --- a/src/core/cpu_core_manager.cpp +++ b/src/core/cpu_core_manager.cpp @@ -130,10 +130,10 @@ void CpuCoreManager::RunLoop(bool tight_loop) { keep_running = false; for (active_core = 0; active_core < NUM_CPU_CORES; ++active_core) { core_timing.SwitchContext(active_core); - if (core_timing.CurrentContextCanRun()) { + if (core_timing.CanCurrentContextRun()) { cores[active_core]->RunLoop(tight_loop); } - keep_running |= core_timing.CurrentContextCanRun(); + keep_running |= core_timing.CanCurrentContextRun(); } } while (keep_running); -- cgit v1.2.3