From 8deaac8bd1707f56f29d61e427ad53964a0920fd Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 7 Apr 2022 16:01:26 -0700 Subject: hle: kernel: Use std::mutex instead of spin locks for most kernel locking. --- src/core/hle/kernel/k_thread.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/core/hle/kernel/k_thread.h') diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h index d0fd85130..c141fc11b 100644 --- a/src/core/hle/kernel/k_thread.h +++ b/src/core/hle/kernel/k_thread.h @@ -15,6 +15,7 @@ #include "common/common_types.h" #include "common/intrusive_red_black_tree.h" +#include "common/spin_lock.h" #include "core/arm/arm_interface.h" #include "core/hle/kernel/k_affinity_mask.h" #include "core/hle/kernel/k_light_lock.h" @@ -762,7 +763,7 @@ private: s8 priority_inheritance_count{}; bool resource_limit_release_hint{}; StackParameters stack_parameters{}; - KSpinLock context_guard{}; + Common::SpinLock context_guard{}; KSpinLock dummy_wait_lock{}; // For emulation -- cgit v1.2.3 From 3f0b93925f082b6defe9454f16f1260539994217 Mon Sep 17 00:00:00 2001 From: bunnei Date: Mon, 11 Apr 2022 20:57:32 -0700 Subject: core: hle: kernel: k_thread: Rework dummy thread waiting. --- src/core/hle/kernel/k_thread.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/core/hle/kernel/k_thread.h') diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h index c141fc11b..4892fdf76 100644 --- a/src/core/hle/kernel/k_thread.h +++ b/src/core/hle/kernel/k_thread.h @@ -6,6 +6,8 @@ #include #include +#include +#include #include #include #include @@ -257,11 +259,11 @@ public: [[nodiscard]] std::shared_ptr& GetHostContext(); [[nodiscard]] ThreadState GetState() const { - return thread_state & ThreadState::Mask; + return thread_state.load(std::memory_order_relaxed) & ThreadState::Mask; } [[nodiscard]] ThreadState GetRawState() const { - return thread_state; + return thread_state.load(std::memory_order_relaxed); } void SetState(ThreadState state); @@ -643,7 +645,6 @@ public: // blocking as needed. void IfDummyThreadTryWait(); - void IfDummyThreadBeginWait(); void IfDummyThreadEndWait(); private: @@ -764,12 +765,13 @@ private: bool resource_limit_release_hint{}; StackParameters stack_parameters{}; Common::SpinLock context_guard{}; - KSpinLock dummy_wait_lock{}; // For emulation std::shared_ptr host_context{}; bool is_single_core{}; ThreadType thread_type{}; + std::mutex dummy_wait_lock; + std::condition_variable dummy_wait_cv; // For debugging std::vector wait_objects_for_debugging; -- cgit v1.2.3