diff options
author | Fernando Sahmkow <fsahmkow27@gmail.com> | 2020-03-19 18:09:32 +0100 |
---|---|---|
committer | Fernando Sahmkow <fsahmkow27@gmail.com> | 2020-06-27 17:35:52 +0200 |
commit | f2ade343e2492c213ac93680a55e9bed712dac9a (patch) | |
tree | 30bce0eb24a0b2b38310f07fa37c7ba881fc8535 /src/core/cpu_manager.cpp | |
parent | GUI: Make multicore only work with Async and add GUI for multicore. (diff) | |
download | yuzu-f2ade343e2492c213ac93680a55e9bed712dac9a.tar yuzu-f2ade343e2492c213ac93680a55e9bed712dac9a.tar.gz yuzu-f2ade343e2492c213ac93680a55e9bed712dac9a.tar.bz2 yuzu-f2ade343e2492c213ac93680a55e9bed712dac9a.tar.lz yuzu-f2ade343e2492c213ac93680a55e9bed712dac9a.tar.xz yuzu-f2ade343e2492c213ac93680a55e9bed712dac9a.tar.zst yuzu-f2ade343e2492c213ac93680a55e9bed712dac9a.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/cpu_manager.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp index d7bd162bc..2aea95a25 100644 --- a/src/core/cpu_manager.cpp +++ b/src/core/cpu_manager.cpp @@ -242,8 +242,11 @@ void CpuManager::SingleCoreRunGuestLoop() { break; } } - physical_core.ClearExclusive(); system.ExitDynarmicProfile(); + thread->SetPhantomMode(true); + system.CoreTiming().Advance(); + thread->SetPhantomMode(false); + physical_core.ClearExclusive(); PreemptSingleCore(); auto& scheduler = kernel.Scheduler(current_core); scheduler.TryDoContextSwitch(); @@ -255,6 +258,7 @@ void CpuManager::SingleCoreRunIdleThread() { while (true) { auto& physical_core = kernel.CurrentPhysicalCore(); PreemptSingleCore(); + idle_count++; auto& scheduler = physical_core.Scheduler(); scheduler.TryDoContextSwitch(); } @@ -280,15 +284,24 @@ void CpuManager::SingleCoreRunSuspendThread() { void CpuManager::PreemptSingleCore() { preemption_count = 0; std::size_t old_core = current_core; - current_core.store((current_core + 1) % Core::Hardware::NUM_CPU_CORES); auto& scheduler = system.Kernel().Scheduler(old_core); Kernel::Thread* current_thread = scheduler.GetCurrentThread(); + if (idle_count >= 4) { + current_thread->SetPhantomMode(true); + system.CoreTiming().Advance(); + current_thread->SetPhantomMode(false); + } + current_core.store((current_core + 1) % Core::Hardware::NUM_CPU_CORES); scheduler.Unload(); auto& next_scheduler = system.Kernel().Scheduler(current_core); Common::Fiber::YieldTo(current_thread->GetHostContext(), next_scheduler.ControlContext()); /// May have changed scheduler auto& current_scheduler = system.Kernel().Scheduler(current_core); current_scheduler.Reload(); + auto* currrent_thread2 = current_scheduler.GetCurrentThread(); + if (!currrent_thread2->IsIdleThread()) { + idle_count = 0; + } } void CpuManager::SingleCorePause(bool paused) { |