diff options
| author | 2020-03-10 11:50:33 -0400 | |
|---|---|---|
| committer | 2020-06-27 11:35:43 -0400 | |
| commit | a439cdf22ea50f0e39cb51f6dff15fee3b495d16 (patch) | |
| tree | 2c88310d7cca08ef451107d9ae6bd5191e7d72e5 /src/core/cpu_manager.cpp | |
| parent | Synchronization: Correct wide Assertion. (diff) | |
| download | yuzu-a439cdf22ea50f0e39cb51f6dff15fee3b495d16.tar.gz yuzu-a439cdf22ea50f0e39cb51f6dff15fee3b495d16.tar.xz yuzu-a439cdf22ea50f0e39cb51f6dff15fee3b495d16.zip | |
CPU_Manager: Unload/Reload threads on preemption on SingleCore
Diffstat (limited to 'src/core/cpu_manager.cpp')
| -rw-r--r-- | src/core/cpu_manager.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp index e72f89808..95842aad1 100644 --- a/src/core/cpu_manager.cpp +++ b/src/core/cpu_manager.cpp | |||
| @@ -225,7 +225,7 @@ void CpuManager::SingleCoreRunGuestLoop() { | |||
| 225 | } | 225 | } |
| 226 | physical_core.ClearExclusive(); | 226 | physical_core.ClearExclusive(); |
| 227 | PreemptSingleCore(); | 227 | PreemptSingleCore(); |
| 228 | auto& scheduler = physical_core.Scheduler(); | 228 | auto& scheduler = kernel.Scheduler(current_core); |
| 229 | scheduler.TryDoContextSwitch(); | 229 | scheduler.TryDoContextSwitch(); |
| 230 | } | 230 | } |
| 231 | } | 231 | } |
| @@ -260,11 +260,15 @@ void CpuManager::SingleCoreRunSuspendThread() { | |||
| 260 | void CpuManager::PreemptSingleCore() { | 260 | void CpuManager::PreemptSingleCore() { |
| 261 | preemption_count = 0; | 261 | preemption_count = 0; |
| 262 | std::size_t old_core = current_core; | 262 | std::size_t old_core = current_core; |
| 263 | current_core = (current_core + 1) % Core::Hardware::NUM_CPU_CORES; | 263 | current_core.store((current_core + 1) % Core::Hardware::NUM_CPU_CORES); |
| 264 | auto& scheduler = system.Kernel().Scheduler(old_core); | 264 | auto& scheduler = system.Kernel().Scheduler(old_core); |
| 265 | Kernel::Thread* current_thread = system.Kernel().Scheduler(old_core).GetCurrentThread(); | 265 | Kernel::Thread* current_thread = scheduler.GetCurrentThread(); |
| 266 | Kernel::Thread* next_thread = system.Kernel().Scheduler(current_core).GetCurrentThread(); | 266 | scheduler.Unload(); |
| 267 | Common::Fiber::YieldTo(current_thread->GetHostContext(), next_thread->GetHostContext()); | 267 | auto& next_scheduler = system.Kernel().Scheduler(current_core); |
| 268 | Common::Fiber::YieldTo(current_thread->GetHostContext(), next_scheduler.ControlContext()); | ||
| 269 | /// May have changed scheduler | ||
| 270 | auto& current_scheduler = system.Kernel().Scheduler(current_core); | ||
| 271 | current_scheduler.Reload(); | ||
| 268 | } | 272 | } |
| 269 | 273 | ||
| 270 | void CpuManager::SingleCorePause(bool paused) { | 274 | void CpuManager::SingleCorePause(bool paused) { |