diff options
Diffstat (limited to 'src/core/core_cpu.cpp')
| -rw-r--r-- | src/core/core_cpu.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/core/core_cpu.cpp b/src/core/core_cpu.cpp index 81c0e212d..6bdfdd7df 100644 --- a/src/core/core_cpu.cpp +++ b/src/core/core_cpu.cpp | |||
| @@ -2,6 +2,9 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <condition_variable> | ||
| 6 | #include <mutex> | ||
| 7 | |||
| 5 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 6 | #ifdef ARCHITECTURE_x86_64 | 9 | #ifdef ARCHITECTURE_x86_64 |
| 7 | #include "core/arm/dynarmic/arm_dynarmic.h" | 10 | #include "core/arm/dynarmic/arm_dynarmic.h" |
| @@ -16,7 +19,9 @@ | |||
| 16 | 19 | ||
| 17 | namespace Core { | 20 | namespace Core { |
| 18 | 21 | ||
| 19 | Cpu::Cpu() { | 22 | Cpu::Cpu(std::shared_ptr<CpuBarrier> cpu_barrier, size_t core_index) |
| 23 | : cpu_barrier{std::move(cpu_barrier)}, core_index{core_index} { | ||
| 24 | |||
| 20 | if (Settings::values.use_cpu_jit) { | 25 | if (Settings::values.use_cpu_jit) { |
| 21 | #ifdef ARCHITECTURE_x86_64 | 26 | #ifdef ARCHITECTURE_x86_64 |
| 22 | arm_interface = std::make_shared<ARM_Dynarmic>(); | 27 | arm_interface = std::make_shared<ARM_Dynarmic>(); |
| @@ -32,15 +37,25 @@ Cpu::Cpu() { | |||
| 32 | } | 37 | } |
| 33 | 38 | ||
| 34 | void Cpu::RunLoop(bool tight_loop) { | 39 | void Cpu::RunLoop(bool tight_loop) { |
| 40 | // Wait for all other CPU cores to complete the previous slice, such that they run in lock-step | ||
| 41 | cpu_barrier->Rendezvous(); | ||
| 42 | |||
| 35 | // If we don't have a currently active thread then don't execute instructions, | 43 | // If we don't have a currently active thread then don't execute instructions, |
| 36 | // instead advance to the next event and try to yield to the next thread | 44 | // instead advance to the next event and try to yield to the next thread |
| 37 | if (Kernel::GetCurrentThread() == nullptr) { | 45 | if (Kernel::GetCurrentThread() == nullptr) { |
| 38 | NGLOG_TRACE(Core, "Idling"); | 46 | NGLOG_TRACE(Core, "Core-{} idling", core_index); |
| 39 | CoreTiming::Idle(); | 47 | |
| 40 | CoreTiming::Advance(); | 48 | if (IsMainCore()) { |
| 49 | CoreTiming::Idle(); | ||
| 50 | CoreTiming::Advance(); | ||
| 51 | } | ||
| 52 | |||
| 41 | PrepareReschedule(); | 53 | PrepareReschedule(); |
| 42 | } else { | 54 | } else { |
| 43 | CoreTiming::Advance(); | 55 | if (IsMainCore()) { |
| 56 | CoreTiming::Advance(); | ||
| 57 | } | ||
| 58 | |||
| 44 | if (tight_loop) { | 59 | if (tight_loop) { |
| 45 | arm_interface->Run(); | 60 | arm_interface->Run(); |
| 46 | } else { | 61 | } else { |