diff options
| author | 2022-01-17 18:48:14 -0800 | |
|---|---|---|
| committer | 2022-01-20 17:08:00 -0800 | |
| commit | 46a620f9d7c0fa2a4f1143ebf28bba4fee12d1a1 (patch) | |
| tree | 5d1a3174fc8285e9388277e7e7d877de0425aa82 | |
| parent | hle: kernel: service_thread: Ensure dummy thread is closed & destroyed on thr... (diff) | |
| download | yuzu-46a620f9d7c0fa2a4f1143ebf28bba4fee12d1a1.tar.gz yuzu-46a620f9d7c0fa2a4f1143ebf28bba4fee12d1a1.tar.xz yuzu-46a620f9d7c0fa2a4f1143ebf28bba4fee12d1a1.zip | |
hle: kernel: KThread: Decrease DummyThread priority to ensure it is never scheduled.
Diffstat (limited to '')
| -rw-r--r-- | src/core/hle/kernel/k_scheduler.cpp | 1 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_thread.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_thread.h | 1 |
3 files changed, 5 insertions, 2 deletions
diff --git a/src/core/hle/kernel/k_scheduler.cpp b/src/core/hle/kernel/k_scheduler.cpp index 5d39a1d4a..1b2a01869 100644 --- a/src/core/hle/kernel/k_scheduler.cpp +++ b/src/core/hle/kernel/k_scheduler.cpp | |||
| @@ -741,6 +741,7 @@ void KScheduler::ScheduleImpl() { | |||
| 741 | 741 | ||
| 742 | // We never want to schedule a dummy thread, as these are only used by host threads for locking. | 742 | // We never want to schedule a dummy thread, as these are only used by host threads for locking. |
| 743 | if (next_thread->GetThreadType() == ThreadType::Dummy) { | 743 | if (next_thread->GetThreadType() == ThreadType::Dummy) { |
| 744 | ASSERT_MSG(false, "Dummy threads should never be scheduled!"); | ||
| 744 | next_thread = idle_thread; | 745 | next_thread = idle_thread; |
| 745 | } | 746 | } |
| 746 | 747 | ||
diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp index 35c4a7581..a599723e6 100644 --- a/src/core/hle/kernel/k_thread.cpp +++ b/src/core/hle/kernel/k_thread.cpp | |||
| @@ -106,7 +106,7 @@ KThread::~KThread() = default; | |||
| 106 | ResultCode KThread::Initialize(KThreadFunction func, uintptr_t arg, VAddr user_stack_top, s32 prio, | 106 | ResultCode KThread::Initialize(KThreadFunction func, uintptr_t arg, VAddr user_stack_top, s32 prio, |
| 107 | s32 virt_core, KProcess* owner, ThreadType type) { | 107 | s32 virt_core, KProcess* owner, ThreadType type) { |
| 108 | // Assert parameters are valid. | 108 | // Assert parameters are valid. |
| 109 | ASSERT((type == ThreadType::Main) || | 109 | ASSERT((type == ThreadType::Main) || (type == ThreadType::Dummy) || |
| 110 | (Svc::HighestThreadPriority <= prio && prio <= Svc::LowestThreadPriority)); | 110 | (Svc::HighestThreadPriority <= prio && prio <= Svc::LowestThreadPriority)); |
| 111 | ASSERT((owner != nullptr) || (type != ThreadType::User)); | 111 | ASSERT((owner != nullptr) || (type != ThreadType::User)); |
| 112 | ASSERT(0 <= virt_core && virt_core < static_cast<s32>(Common::BitSize<u64>())); | 112 | ASSERT(0 <= virt_core && virt_core < static_cast<s32>(Common::BitSize<u64>())); |
| @@ -262,7 +262,7 @@ ResultCode KThread::InitializeThread(KThread* thread, KThreadFunction func, uint | |||
| 262 | } | 262 | } |
| 263 | 263 | ||
| 264 | ResultCode KThread::InitializeDummyThread(KThread* thread) { | 264 | ResultCode KThread::InitializeDummyThread(KThread* thread) { |
| 265 | return thread->Initialize({}, {}, {}, DefaultThreadPriority, 3, {}, ThreadType::Dummy); | 265 | return thread->Initialize({}, {}, {}, DummyThreadPriority, 3, {}, ThreadType::Dummy); |
| 266 | } | 266 | } |
| 267 | 267 | ||
| 268 | ResultCode KThread::InitializeIdleThread(Core::System& system, KThread* thread, s32 virt_core) { | 268 | ResultCode KThread::InitializeIdleThread(Core::System& system, KThread* thread, s32 virt_core) { |
| @@ -1099,6 +1099,7 @@ void KThread::EndWait(ResultCode wait_result_) { | |||
| 1099 | 1099 | ||
| 1100 | // Dummy threads are just used by host threads for locking, and will never have a wait_queue. | 1100 | // Dummy threads are just used by host threads for locking, and will never have a wait_queue. |
| 1101 | if (thread_type == ThreadType::Dummy) { | 1101 | if (thread_type == ThreadType::Dummy) { |
| 1102 | ASSERT_MSG(false, "Dummy threads should never call EndWait!"); | ||
| 1102 | return; | 1103 | return; |
| 1103 | } | 1104 | } |
| 1104 | 1105 | ||
diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h index 86d4b7c55..77b53a198 100644 --- a/src/core/hle/kernel/k_thread.h +++ b/src/core/hle/kernel/k_thread.h | |||
| @@ -112,6 +112,7 @@ private: | |||
| 112 | public: | 112 | public: |
| 113 | static constexpr s32 DefaultThreadPriority = 44; | 113 | static constexpr s32 DefaultThreadPriority = 44; |
| 114 | static constexpr s32 IdleThreadPriority = Svc::LowestThreadPriority + 1; | 114 | static constexpr s32 IdleThreadPriority = Svc::LowestThreadPriority + 1; |
| 115 | static constexpr s32 DummyThreadPriority = Svc::LowestThreadPriority + 2; | ||
| 115 | 116 | ||
| 116 | explicit KThread(KernelCore& kernel_); | 117 | explicit KThread(KernelCore& kernel_); |
| 117 | ~KThread() override; | 118 | ~KThread() override; |