summaryrefslogtreecommitdiffstats
path: root/src/core/cpu_manager.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2020-12-06 09:16:39 +0100
committerbunnei <bunneidev@gmail.com>2020-12-06 09:27:13 +0100
commitd4ae0ae0e9077c41499bb6a1d4bed2e047312748 (patch)
treed23a00cc127b6f548e49ebb9179617149d76de29 /src/core/cpu_manager.cpp
parenthle: kernel: Thread: Various style fixes based on code review feedback. (diff)
downloadyuzu-d4ae0ae0e9077c41499bb6a1d4bed2e047312748.tar
yuzu-d4ae0ae0e9077c41499bb6a1d4bed2e047312748.tar.gz
yuzu-d4ae0ae0e9077c41499bb6a1d4bed2e047312748.tar.bz2
yuzu-d4ae0ae0e9077c41499bb6a1d4bed2e047312748.tar.lz
yuzu-d4ae0ae0e9077c41499bb6a1d4bed2e047312748.tar.xz
yuzu-d4ae0ae0e9077c41499bb6a1d4bed2e047312748.tar.zst
yuzu-d4ae0ae0e9077c41499bb6a1d4bed2e047312748.zip
Diffstat (limited to 'src/core/cpu_manager.cpp')
-rw-r--r--src/core/cpu_manager.cpp47
1 files changed, 26 insertions, 21 deletions
diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp
index 179154348..373395047 100644
--- a/src/core/cpu_manager.cpp
+++ b/src/core/cpu_manager.cpp
@@ -254,29 +254,34 @@ void CpuManager::SingleCoreRunSuspendThread() {
}
void CpuManager::PreemptSingleCore(bool from_running_enviroment) {
- std::size_t old_core = current_core;
- auto& scheduler = system.Kernel().Scheduler(old_core);
- Kernel::Thread* current_thread = scheduler.GetCurrentThread();
- if (idle_count >= 4 || from_running_enviroment) {
- if (!from_running_enviroment) {
- system.CoreTiming().Idle();
- idle_count = 0;
+ {
+ auto& scheduler = system.Kernel().Scheduler(current_core);
+ Kernel::Thread* current_thread = scheduler.GetCurrentThread();
+ if (idle_count >= 4 || from_running_enviroment) {
+ if (!from_running_enviroment) {
+ system.CoreTiming().Idle();
+ idle_count = 0;
+ }
+ current_thread->SetPhantomMode(true);
+ system.CoreTiming().Advance();
+ current_thread->SetPhantomMode(false);
}
- current_thread->SetPhantomMode(true);
- system.CoreTiming().Advance();
- current_thread->SetPhantomMode(false);
+ current_core.store((current_core + 1) % Core::Hardware::NUM_CPU_CORES);
+ system.CoreTiming().ResetTicks();
+ scheduler.Unload(scheduler.GetCurrentThread());
+
+ auto& next_scheduler = system.Kernel().Scheduler(current_core);
+ Common::Fiber::YieldTo(current_thread->GetHostContext(), next_scheduler.ControlContext());
}
- current_core.store((current_core + 1) % Core::Hardware::NUM_CPU_CORES);
- system.CoreTiming().ResetTicks();
- scheduler.Unload(scheduler.GetCurrentThread());
- 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(scheduler.GetCurrentThread());
- auto* currrent_thread2 = current_scheduler.GetCurrentThread();
- if (!currrent_thread2->IsIdleThread()) {
- idle_count = 0;
+
+ // May have changed scheduler
+ {
+ auto& scheduler = system.Kernel().Scheduler(current_core);
+ scheduler.Reload(scheduler.GetCurrentThread());
+ auto* currrent_thread2 = scheduler.GetCurrentThread();
+ if (!currrent_thread2->IsIdleThread()) {
+ idle_count = 0;
+ }
}
}