diff options
author | Liam <byteslice@airmail.cc> | 2022-07-11 16:13:13 +0200 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2022-07-15 04:47:18 +0200 |
commit | a9a83fa726b43a28f4e5a40516efd56fbf99009f (patch) | |
tree | 1f9de785b3af0d31ca19aa7d5770437fe17902c1 | |
parent | kernel: be more careful about initialization path for HLE threads (diff) | |
download | yuzu-a9a83fa726b43a28f4e5a40516efd56fbf99009f.tar yuzu-a9a83fa726b43a28f4e5a40516efd56fbf99009f.tar.gz yuzu-a9a83fa726b43a28f4e5a40516efd56fbf99009f.tar.bz2 yuzu-a9a83fa726b43a28f4e5a40516efd56fbf99009f.tar.lz yuzu-a9a83fa726b43a28f4e5a40516efd56fbf99009f.tar.xz yuzu-a9a83fa726b43a28f4e5a40516efd56fbf99009f.tar.zst yuzu-a9a83fa726b43a28f4e5a40516efd56fbf99009f.zip |
-rw-r--r-- | src/core/hle/kernel/k_scheduler.cpp | 21 | ||||
-rw-r--r-- | src/core/hle/kernel/k_scheduler.h | 2 | ||||
-rw-r--r-- | src/core/hle/kernel/k_thread.cpp | 8 |
3 files changed, 21 insertions, 10 deletions
diff --git a/src/core/hle/kernel/k_scheduler.cpp b/src/core/hle/kernel/k_scheduler.cpp index d9ba8e409..c34ce7a17 100644 --- a/src/core/hle/kernel/k_scheduler.cpp +++ b/src/core/hle/kernel/k_scheduler.cpp @@ -63,14 +63,8 @@ void KScheduler::EnableScheduling(KernelCore& kernel, u64 cores_needing_scheduli auto* scheduler{kernel.CurrentScheduler()}; if (!scheduler || kernel.IsPhantomModeForSingleCore()) { - // HACK: we cannot schedule from this thread, it is not a core thread - RescheduleCores(kernel, cores_needing_scheduling); - if (GetCurrentThread(kernel).GetDisableDispatchCount() == 1) { - // Special case to ensure dummy threads that are waiting block - GetCurrentThread(kernel).IfDummyThreadTryWait(); - } - GetCurrentThread(kernel).EnableDispatch(); - ASSERT(GetCurrentThread(kernel).GetState() != ThreadState::Waiting); + KScheduler::RescheduleCores(kernel, cores_needing_scheduling); + KScheduler::RescheduleCurrentHLEThread(kernel); return; } @@ -83,6 +77,17 @@ void KScheduler::EnableScheduling(KernelCore& kernel, u64 cores_needing_scheduli } } +void KScheduler::RescheduleCurrentHLEThread(KernelCore& kernel) { + // HACK: we cannot schedule from this thread, it is not a core thread + ASSERT(GetCurrentThread(kernel).GetDisableDispatchCount() == 1); + + // Special case to ensure dummy threads that are waiting block + GetCurrentThread(kernel).IfDummyThreadTryWait(); + + ASSERT(GetCurrentThread(kernel).GetState() != ThreadState::Waiting); + GetCurrentThread(kernel).EnableDispatch(); +} + u64 KScheduler::UpdateHighestPriorityThreads(KernelCore& kernel) { if (IsSchedulerUpdateNeeded(kernel)) { return UpdateHighestPriorityThreadsImpl(kernel); diff --git a/src/core/hle/kernel/k_scheduler.h b/src/core/hle/kernel/k_scheduler.h index ac7421c9a..534321d8d 100644 --- a/src/core/hle/kernel/k_scheduler.h +++ b/src/core/hle/kernel/k_scheduler.h @@ -119,6 +119,8 @@ private: } static u64 UpdateHighestPriorityThreadsImpl(KernelCore& kernel); + static void RescheduleCurrentHLEThread(KernelCore& kernel); + // Instanced private API. void ScheduleImpl(); void ScheduleImplFiber(); diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp index 985ce448e..174afc80d 100644 --- a/src/core/hle/kernel/k_thread.cpp +++ b/src/core/hle/kernel/k_thread.cpp @@ -1106,6 +1106,8 @@ void KThread::IfDummyThreadTryWait() { return; } + ASSERT(!kernel.IsPhantomModeForSingleCore()); + // Block until we are no longer waiting. std::unique_lock lk(dummy_wait_lock); dummy_wait_cv.wait( @@ -1211,10 +1213,12 @@ KScopedDisableDispatch::~KScopedDisableDispatch() { } if (GetCurrentThread(kernel).GetDisableDispatchCount() <= 1) { - auto scheduler = kernel.CurrentScheduler(); + auto* scheduler = kernel.CurrentScheduler(); - if (scheduler) { + if (scheduler && !kernel.IsPhantomModeForSingleCore()) { scheduler->RescheduleCurrentCore(); + } else { + KScheduler::RescheduleCurrentHLEThread(kernel); } } else { GetCurrentThread(kernel).EnableDispatch(); |