summaryrefslogtreecommitdiffstats
path: root/src/core/core_cpu.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-05-03 03:26:14 +0200
committerbunnei <bunneidev@gmail.com>2018-05-11 01:34:46 +0200
commit9776ff91797423a9cf19571faafe4648fb5a1d1d (patch)
tree46a7c94c53faee26b805f6290a09c45d33f7bf11 /src/core/core_cpu.cpp
parentcore: Move common CPU core things to its own class. (diff)
downloadyuzu-9776ff91797423a9cf19571faafe4648fb5a1d1d.tar
yuzu-9776ff91797423a9cf19571faafe4648fb5a1d1d.tar.gz
yuzu-9776ff91797423a9cf19571faafe4648fb5a1d1d.tar.bz2
yuzu-9776ff91797423a9cf19571faafe4648fb5a1d1d.tar.lz
yuzu-9776ff91797423a9cf19571faafe4648fb5a1d1d.tar.xz
yuzu-9776ff91797423a9cf19571faafe4648fb5a1d1d.tar.zst
yuzu-9776ff91797423a9cf19571faafe4648fb5a1d1d.zip
Diffstat (limited to '')
-rw-r--r--src/core/core_cpu.cpp25
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 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
+#include <condition_variable>
+#include <mutex>
+
#include "common/logging/log.h"
#ifdef ARCHITECTURE_x86_64
#include "core/arm/dynarmic/arm_dynarmic.h"
@@ -16,7 +19,9 @@
namespace Core {
-Cpu::Cpu() {
+Cpu::Cpu(std::shared_ptr<CpuBarrier> cpu_barrier, size_t core_index)
+ : cpu_barrier{std::move(cpu_barrier)}, core_index{core_index} {
+
if (Settings::values.use_cpu_jit) {
#ifdef ARCHITECTURE_x86_64
arm_interface = std::make_shared<ARM_Dynarmic>();
@@ -32,15 +37,25 @@ Cpu::Cpu() {
}
void Cpu::RunLoop(bool tight_loop) {
+ // Wait for all other CPU cores to complete the previous slice, such that they run in lock-step
+ cpu_barrier->Rendezvous();
+
// If we don't have a currently active thread then don't execute instructions,
// instead advance to the next event and try to yield to the next thread
if (Kernel::GetCurrentThread() == nullptr) {
- NGLOG_TRACE(Core, "Idling");
- CoreTiming::Idle();
- CoreTiming::Advance();
+ NGLOG_TRACE(Core, "Core-{} idling", core_index);
+
+ if (IsMainCore()) {
+ CoreTiming::Idle();
+ CoreTiming::Advance();
+ }
+
PrepareReschedule();
} else {
- CoreTiming::Advance();
+ if (IsMainCore()) {
+ CoreTiming::Advance();
+ }
+
if (tight_loop) {
arm_interface->Run();
} else {