소스 검색

cpu_manager: properly check idle on return from preemption

Liam 4 년 전
부모
커밋
2c1e2c63c3
2개의 변경된 파일8개의 추가작업 그리고 1개의 파일을 삭제
  1. 3 1
      src/core/cpu_manager.cpp
  2. 5 0
      src/core/hle/kernel/k_scheduler.h

+ 3 - 1
src/core/cpu_manager.cpp

@@ -194,7 +194,9 @@ void CpuManager::PreemptSingleCore(bool from_running_enviroment) {
     {
         auto& scheduler = system.Kernel().Scheduler(current_core);
         scheduler.Reload(scheduler.GetSchedulerCurrentThread());
-        idle_count = 0;
+        if (!scheduler.IsIdle()) {
+            idle_count = 0;
+        }
     }
 }
 

+ 5 - 0
src/core/hle/kernel/k_scheduler.h

@@ -55,6 +55,11 @@ public:
         return idle_thread;
     }
 
+    /// Returns true if the scheduler is idle
+    [[nodiscard]] bool IsIdle() const {
+        return GetSchedulerCurrentThread() == idle_thread;
+    }
+
     /// Gets the timestamp for the last context switch in ticks.
     [[nodiscard]] u64 GetLastContextSwitchTicks() const;