diff options
author | bunnei <bunneidev@gmail.com> | 2021-01-20 22:42:27 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2021-01-29 06:42:26 +0100 |
commit | cdd14b03e5c8e29bc6cd11bbde0ef726d2f166ce (patch) | |
tree | 987f6cb5d3f1955dc88f5ac2c1d5c1329d787fc4 /src/core/hle/kernel/k_scheduler.h | |
parent | kernel: svc_types: Add ThreadActivity. (diff) | |
download | yuzu-cdd14b03e5c8e29bc6cd11bbde0ef726d2f166ce.tar yuzu-cdd14b03e5c8e29bc6cd11bbde0ef726d2f166ce.tar.gz yuzu-cdd14b03e5c8e29bc6cd11bbde0ef726d2f166ce.tar.bz2 yuzu-cdd14b03e5c8e29bc6cd11bbde0ef726d2f166ce.tar.lz yuzu-cdd14b03e5c8e29bc6cd11bbde0ef726d2f166ce.tar.xz yuzu-cdd14b03e5c8e29bc6cd11bbde0ef726d2f166ce.tar.zst yuzu-cdd14b03e5c8e29bc6cd11bbde0ef726d2f166ce.zip |
Diffstat (limited to 'src/core/hle/kernel/k_scheduler.h')
-rw-r--r-- | src/core/hle/kernel/k_scheduler.h | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/core/hle/kernel/k_scheduler.h b/src/core/hle/kernel/k_scheduler.h index 157373934..2308a55be 100644 --- a/src/core/hle/kernel/k_scheduler.h +++ b/src/core/hle/kernel/k_scheduler.h @@ -33,15 +33,14 @@ class KThread; class KScheduler final { public: - explicit KScheduler(Core::System& system, std::size_t core_id); + explicit KScheduler(Core::System& system, s32 core_id); ~KScheduler(); /// Reschedules to the next available thread (call after current thread is suspended) void RescheduleCurrentCore(); /// Reschedules cores pending reschedule, to be called on EnableScheduling. - static void RescheduleCores(KernelCore& kernel, u64 cores_pending_reschedule, - Core::EmuThreadHandle global_thread); + static void RescheduleCores(KernelCore& kernel, u64 cores_pending_reschedule); /// The next two are for SingleCore Only. /// Unload current thread before preempting core. @@ -53,6 +52,11 @@ public: /// Gets the current running thread [[nodiscard]] KThread* GetCurrentThread() const; + /// Returns true if the scheduler is idle + [[nodiscard]] bool IsIdle() const { + return GetCurrentThread() == idle_thread; + } + /// Gets the timestamp for the last context switch in ticks. [[nodiscard]] u64 GetLastContextSwitchTicks() const; @@ -79,7 +83,7 @@ public: * * @note This operation can be redundant and no scheduling is changed if marked as so. */ - void YieldWithoutCoreMigration(); + static void YieldWithoutCoreMigration(KernelCore& kernel); /** * Takes a thread and moves it to the back of the it's priority list. @@ -88,7 +92,7 @@ public: * * @note This operation can be redundant and no scheduling is changed if marked as so. */ - void YieldWithCoreMigration(); + static void YieldWithCoreMigration(KernelCore& kernel); /** * Takes a thread and moves it out of the scheduling queue. @@ -97,7 +101,9 @@ public: * * @note This operation can be redundant and no scheduling is changed if marked as so. */ - void YieldToAnyThread(); + static void YieldToAnyThread(KernelCore& kernel); + + static void ClearPreviousThread(KernelCore& kernel, KThread* thread); /// Notify the scheduler a thread's status has changed. static void OnThreadStateChanged(KernelCore& kernel, KThread* thread, ThreadState old_state); @@ -114,8 +120,7 @@ public: static void SetSchedulerUpdateNeeded(KernelCore& kernel); static void ClearSchedulerUpdateNeeded(KernelCore& kernel); static void DisableScheduling(KernelCore& kernel); - static void EnableScheduling(KernelCore& kernel, u64 cores_needing_scheduling, - Core::EmuThreadHandle global_thread); + static void EnableScheduling(KernelCore& kernel, u64 cores_needing_scheduling); [[nodiscard]] static u64 UpdateHighestPriorityThreads(KernelCore& kernel); private: @@ -168,6 +173,7 @@ private: static void OnSwitch(void* this_scheduler); void SwitchToCurrent(); + KThread* prev_thread{}; KThread* current_thread{}; KThread* idle_thread{}; @@ -186,7 +192,7 @@ private: Core::System& system; u64 last_context_switch_time{}; - const std::size_t core_id; + const s32 core_id; Common::SpinLock guard{}; }; |