summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/kernel.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2022-01-21 22:34:47 -0800
committerGravatar GitHub2022-01-21 22:34:47 -0800
commit68c8a1b17093dabfaf8558163b6f7ff326ac9938 (patch)
tree4a8965dd8c142333e681564a8da803c2e4a45a56 /src/core/hle/kernel/kernel.cpp
parentMerge pull request #7752 from Morph1984/SetCpuOverclockEnabled (diff)
parenthle: kernel: KThread: Ensure host (dummy) threads block on locking. (diff)
downloadyuzu-68c8a1b17093dabfaf8558163b6f7ff326ac9938.tar.gz
yuzu-68c8a1b17093dabfaf8558163b6f7ff326ac9938.tar.xz
yuzu-68c8a1b17093dabfaf8558163b6f7ff326ac9938.zip
Merge pull request #7737 from bunnei/fix-dummy-thread-leak
Various fixes to HLE service thread management
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
-rw-r--r--src/core/hle/kernel/kernel.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 887c1fd27..49c0714ed 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -301,12 +301,10 @@ struct KernelCore::Impl {
301 // Gets the dummy KThread for the caller, allocating a new one if this is the first time 301 // Gets the dummy KThread for the caller, allocating a new one if this is the first time
302 KThread* GetHostDummyThread() { 302 KThread* GetHostDummyThread() {
303 auto make_thread = [this]() { 303 auto make_thread = [this]() {
304 std::lock_guard lk(dummy_thread_lock); 304 KThread* thread = KThread::Create(system.Kernel());
305 auto& thread = dummy_threads.emplace_back(std::make_unique<KThread>(system.Kernel())); 305 ASSERT(KThread::InitializeDummyThread(thread).IsSuccess());
306 KAutoObject::Create(thread.get());
307 ASSERT(KThread::InitializeDummyThread(thread.get()).IsSuccess());
308 thread->SetName(fmt::format("DummyThread:{}", GetHostThreadId())); 306 thread->SetName(fmt::format("DummyThread:{}", GetHostThreadId()));
309 return thread.get(); 307 return thread;
310 }; 308 };
311 309
312 thread_local KThread* saved_thread = make_thread(); 310 thread_local KThread* saved_thread = make_thread();
@@ -731,7 +729,6 @@ struct KernelCore::Impl {
731 std::mutex server_sessions_lock; 729 std::mutex server_sessions_lock;
732 std::mutex registered_objects_lock; 730 std::mutex registered_objects_lock;
733 std::mutex registered_in_use_objects_lock; 731 std::mutex registered_in_use_objects_lock;
734 std::mutex dummy_thread_lock;
735 732
736 std::atomic<u32> next_object_id{0}; 733 std::atomic<u32> next_object_id{0};
737 std::atomic<u64> next_kernel_process_id{KProcess::InitialKIPIDMin}; 734 std::atomic<u64> next_kernel_process_id{KProcess::InitialKIPIDMin};
@@ -788,9 +785,6 @@ struct KernelCore::Impl {
788 std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES> interrupts{}; 785 std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES> interrupts{};
789 std::array<std::unique_ptr<Kernel::KScheduler>, Core::Hardware::NUM_CPU_CORES> schedulers{}; 786 std::array<std::unique_ptr<Kernel::KScheduler>, Core::Hardware::NUM_CPU_CORES> schedulers{};
790 787
791 // Specifically tracked to be automatically destroyed with kernel
792 std::vector<std::unique_ptr<KThread>> dummy_threads;
793
794 bool is_multicore{}; 788 bool is_multicore{};
795 std::atomic_bool is_shutting_down{}; 789 std::atomic_bool is_shutting_down{};
796 bool is_phantom_mode_for_singlecore{}; 790 bool is_phantom_mode_for_singlecore{};