aboutsummaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/k_thread.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2022-01-21 22:34:47 -0800
committerGitHub <noreply@github.com>2022-01-21 22:34:47 -0800
commit68c8a1b17093dabfaf8558163b6f7ff326ac9938 (patch)
tree4a8965dd8c142333e681564a8da803c2e4a45a56 /src/core/hle/kernel/k_thread.h
parentcef7649bedc2c8bf35fa52e58538b48030a1d266 (diff)
parent615fb40416b9ee10abf40a036b31d1540886a9b8 (diff)
Merge pull request #7737 from bunnei/fix-dummy-thread-leak
Various fixes to HLE service thread management
Diffstat (limited to 'src/core/hle/kernel/k_thread.h')
-rw-r--r--src/core/hle/kernel/k_thread.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h
index cc427f6cf..d058db62c 100644
--- a/src/core/hle/kernel/k_thread.h
+++ b/src/core/hle/kernel/k_thread.h
@@ -112,6 +112,7 @@ private:
public:
static constexpr s32 DefaultThreadPriority = 44;
static constexpr s32 IdleThreadPriority = Svc::LowestThreadPriority + 1;
+ static constexpr s32 DummyThreadPriority = Svc::LowestThreadPriority + 2;
explicit KThread(KernelCore& kernel_);
~KThread() override;
@@ -553,8 +554,12 @@ public:
return wait_reason_for_debugging;
}
- [[nodiscard]] ThreadType GetThreadTypeForDebugging() const {
- return thread_type_for_debugging;
+ [[nodiscard]] ThreadType GetThreadType() const {
+ return thread_type;
+ }
+
+ [[nodiscard]] bool IsDummyThread() const {
+ return GetThreadType() == ThreadType::Dummy;
}
void SetWaitObjectsForDebugging(const std::span<KSynchronizationObject*>& objects) {
@@ -631,6 +636,14 @@ public:
return condvar_key;
}
+ // Dummy threads (used for HLE host threads) cannot wait based on the guest scheduler, and
+ // therefore will not block on guest kernel synchronization primitives. These methods handle
+ // blocking as needed.
+
+ void IfDummyThreadTryWait();
+ void IfDummyThreadBeginWait();
+ void IfDummyThreadEndWait();
+
private:
static constexpr size_t PriorityInheritanceCountMax = 10;
union SyncObjectBuffer {
@@ -749,16 +762,17 @@ private:
bool resource_limit_release_hint{};
StackParameters stack_parameters{};
KSpinLock context_guard{};
+ KSpinLock dummy_wait_lock{};
// For emulation
std::shared_ptr<Common::Fiber> host_context{};
bool is_single_core{};
+ ThreadType thread_type{};
// For debugging
std::vector<KSynchronizationObject*> wait_objects_for_debugging;
VAddr mutex_wait_address_for_debugging{};
ThreadWaitReasonForDebugging wait_reason_for_debugging{};
- ThreadType thread_type_for_debugging{};
public:
using ConditionVariableThreadTreeType = ConditionVariableThreadTree;