diff options
author | bunnei <bunneidev@gmail.com> | 2022-11-10 00:52:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-10 00:52:23 +0100 |
commit | 770f23db341c6fad8c2647b6c0015348f6dc8730 (patch) | |
tree | 9cbb82f96454f27657a539e212f6f0852932ed35 /src/core/hle/kernel/service_thread.cpp | |
parent | Merge pull request #9215 from liamwhite/swordfight (diff) | |
parent | service_thread: register service threads to the logical owner process (diff) | |
download | yuzu-770f23db341c6fad8c2647b6c0015348f6dc8730.tar yuzu-770f23db341c6fad8c2647b6c0015348f6dc8730.tar.gz yuzu-770f23db341c6fad8c2647b6c0015348f6dc8730.tar.bz2 yuzu-770f23db341c6fad8c2647b6c0015348f6dc8730.tar.lz yuzu-770f23db341c6fad8c2647b6c0015348f6dc8730.tar.xz yuzu-770f23db341c6fad8c2647b6c0015348f6dc8730.tar.zst yuzu-770f23db341c6fad8c2647b6c0015348f6dc8730.zip |
Diffstat (limited to 'src/core/hle/kernel/service_thread.cpp')
-rw-r--r-- | src/core/hle/kernel/service_thread.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/core/hle/kernel/service_thread.cpp b/src/core/hle/kernel/service_thread.cpp index c8fe42537..7a85be77f 100644 --- a/src/core/hle/kernel/service_thread.cpp +++ b/src/core/hle/kernel/service_thread.cpp @@ -36,11 +36,12 @@ public: private: KernelCore& kernel; - std::jthread m_thread; + std::jthread m_host_thread; std::mutex m_session_mutex; std::map<KServerSession*, std::shared_ptr<SessionRequestManager>> m_sessions; KEvent* m_wakeup_event; KProcess* m_process; + KThread* m_thread; std::atomic<bool> m_shutdown_requested; const std::string m_service_name; }; @@ -132,7 +133,7 @@ void ServiceThread::Impl::SessionClosed(KServerSession* server_session, void ServiceThread::Impl::LoopProcess() { Common::SetCurrentThreadName(m_service_name.c_str()); - kernel.RegisterHostThread(); + kernel.RegisterHostThread(m_thread); while (!m_shutdown_requested.load()) { WaitAndProcessImpl(); @@ -160,7 +161,7 @@ ServiceThread::Impl::~Impl() { // Shut down the processing thread. m_shutdown_requested.store(true); m_wakeup_event->Signal(); - m_thread.join(); + m_host_thread.join(); // Lock mutex. m_session_mutex.lock(); @@ -177,6 +178,9 @@ ServiceThread::Impl::~Impl() { m_wakeup_event->GetReadableEvent().Close(); m_wakeup_event->Close(); + // Close thread. + m_thread->Close(); + // Close process. m_process->Close(); } @@ -199,11 +203,19 @@ ServiceThread::Impl::Impl(KernelCore& kernel_, const std::string& service_name) // Commit the event reservation. event_reservation.Commit(); - // Register the event. - KEvent::Register(kernel, m_wakeup_event); + // Reserve a new thread from the process resource limit + KScopedResourceReservation thread_reservation(m_process, LimitableResource::Threads); + ASSERT(thread_reservation.Succeeded()); + + // Initialize thread. + m_thread = KThread::Create(kernel); + ASSERT(KThread::InitializeDummyThread(m_thread, m_process).IsSuccess()); + + // Commit the thread reservation. + thread_reservation.Commit(); // Start thread. - m_thread = std::jthread([this] { LoopProcess(); }); + m_host_thread = std::jthread([this] { LoopProcess(); }); } ServiceThread::ServiceThread(KernelCore& kernel, const std::string& name) |