diff options
author | bunnei <bunneidev@gmail.com> | 2022-01-22 07:34:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-22 07:34:47 +0100 |
commit | 68c8a1b17093dabfaf8558163b6f7ff326ac9938 (patch) | |
tree | 4a8965dd8c142333e681564a8da803c2e4a45a56 /src/core/hle/kernel/k_thread.h | |
parent | Merge pull request #7752 from Morph1984/SetCpuOverclockEnabled (diff) | |
parent | hle: kernel: KThread: Ensure host (dummy) threads block on locking. (diff) | |
download | yuzu-68c8a1b17093dabfaf8558163b6f7ff326ac9938.tar yuzu-68c8a1b17093dabfaf8558163b6f7ff326ac9938.tar.gz yuzu-68c8a1b17093dabfaf8558163b6f7ff326ac9938.tar.bz2 yuzu-68c8a1b17093dabfaf8558163b6f7ff326ac9938.tar.lz yuzu-68c8a1b17093dabfaf8558163b6f7ff326ac9938.tar.xz yuzu-68c8a1b17093dabfaf8558163b6f7ff326ac9938.tar.zst yuzu-68c8a1b17093dabfaf8558163b6f7ff326ac9938.zip |
Diffstat (limited to 'src/core/hle/kernel/k_thread.h')
-rw-r--r-- | src/core/hle/kernel/k_thread.h | 20 |
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; |