summaryrefslogtreecommitdiffstats
path: root/src/core/cpu_manager.cpp
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2020-02-28 00:12:41 +0100
committerFernando Sahmkow <fsahmkow27@gmail.com>2020-06-27 17:35:20 +0200
commit04e0f8776c26930d7dc8015e53914b11bf1929c1 (patch)
tree4a8288d6bf8655a2ec0595fdc6d41a3037c5fcad /src/core/cpu_manager.cpp
parentSVC: Correct races on physical core switching. (diff)
downloadyuzu-04e0f8776c26930d7dc8015e53914b11bf1929c1.tar
yuzu-04e0f8776c26930d7dc8015e53914b11bf1929c1.tar.gz
yuzu-04e0f8776c26930d7dc8015e53914b11bf1929c1.tar.bz2
yuzu-04e0f8776c26930d7dc8015e53914b11bf1929c1.tar.lz
yuzu-04e0f8776c26930d7dc8015e53914b11bf1929c1.tar.xz
yuzu-04e0f8776c26930d7dc8015e53914b11bf1929c1.tar.zst
yuzu-04e0f8776c26930d7dc8015e53914b11bf1929c1.zip
Diffstat (limited to 'src/core/cpu_manager.cpp')
-rw-r--r--src/core/cpu_manager.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp
index 904aacd97..9a261968a 100644
--- a/src/core/cpu_manager.cpp
+++ b/src/core/cpu_manager.cpp
@@ -46,6 +46,11 @@ void CpuManager::GuestThreadFunction(void* cpu_manager_) {
cpu_manager->RunGuestThread();
}
+void CpuManager::GuestRewindFunction(void* cpu_manager_) {
+ CpuManager* cpu_manager = static_cast<CpuManager*>(cpu_manager_);
+ cpu_manager->RunGuestLoop();
+}
+
void CpuManager::IdleThreadFunction(void* cpu_manager_) {
CpuManager* cpu_manager = static_cast<CpuManager*>(cpu_manager_);
cpu_manager->RunIdleThread();
@@ -78,14 +83,22 @@ void CpuManager::RunGuestThread() {
auto& sched = kernel.CurrentScheduler();
sched.OnThreadStart();
}
+ RunGuestLoop();
+}
+
+void CpuManager::RunGuestLoop() {
+ auto& kernel = system.Kernel();
+ auto* thread = kernel.CurrentScheduler().GetCurrentThread();
+ auto host_context = thread->GetHostContext();
+ host_context->SetRewindPoint(std::function<void(void*)>(GuestRewindFunction), this);
+ host_context.reset();
while (true) {
- auto* physical_core = &kernel.CurrentPhysicalCore();
- while (!physical_core->IsInterrupted()) {
- physical_core->Run();
- physical_core = &kernel.CurrentPhysicalCore();
+ auto& physical_core = kernel.CurrentPhysicalCore();
+ while (!physical_core.IsInterrupted()) {
+ physical_core.Run();
}
- physical_core->ClearExclusive();
- auto& scheduler = physical_core->Scheduler();
+ physical_core.ClearExclusive();
+ auto& scheduler = physical_core.Scheduler();
scheduler.TryDoContextSwitch();
}
}