summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2022-11-12 07:37:04 +0100
committerGitHub <noreply@github.com>2022-11-12 07:37:04 +0100
commitb51c1544b9fff19678a37932c4a87ec9e3e91e2b (patch)
tree59158d60c840dd4e474cf47b463d696cfc0a44cd /src
parentMerge pull request #9231 from goldenx86/corecount (diff)
parentservice_thread: remove explicit KProcess (diff)
downloadyuzu-b51c1544b9fff19678a37932c4a87ec9e3e91e2b.tar
yuzu-b51c1544b9fff19678a37932c4a87ec9e3e91e2b.tar.gz
yuzu-b51c1544b9fff19678a37932c4a87ec9e3e91e2b.tar.bz2
yuzu-b51c1544b9fff19678a37932c4a87ec9e3e91e2b.tar.lz
yuzu-b51c1544b9fff19678a37932c4a87ec9e3e91e2b.tar.xz
yuzu-b51c1544b9fff19678a37932c4a87ec9e3e91e2b.tar.zst
yuzu-b51c1544b9fff19678a37932c4a87ec9e3e91e2b.zip
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/k_event.cpp15
-rw-r--r--src/core/hle/kernel/service_thread.cpp27
2 files changed, 13 insertions, 29 deletions
diff --git a/src/core/hle/kernel/k_event.cpp b/src/core/hle/kernel/k_event.cpp
index 27f70e5c5..d973853ab 100644
--- a/src/core/hle/kernel/k_event.cpp
+++ b/src/core/hle/kernel/k_event.cpp
@@ -20,8 +20,12 @@ void KEvent::Initialize(KProcess* owner) {
m_readable_event.Initialize(this);
// Set our owner process.
- m_owner = owner;
- m_owner->Open();
+ // HACK: this should never be nullptr, but service threads don't have a
+ // proper parent process yet.
+ if (owner != nullptr) {
+ m_owner = owner;
+ m_owner->Open();
+ }
// Mark initialized.
m_initialized = true;
@@ -50,8 +54,11 @@ Result KEvent::Clear() {
void KEvent::PostDestroy(uintptr_t arg) {
// Release the event count resource the owner process holds.
KProcess* owner = reinterpret_cast<KProcess*>(arg);
- owner->GetResourceLimit()->Release(LimitableResource::EventCountMax, 1);
- owner->Close();
+
+ if (owner != nullptr) {
+ owner->GetResourceLimit()->Release(LimitableResource::EventCountMax, 1);
+ owner->Close();
+ }
}
} // namespace Kernel
diff --git a/src/core/hle/kernel/service_thread.cpp b/src/core/hle/kernel/service_thread.cpp
index f5c2ab23f..e6e41ac34 100644
--- a/src/core/hle/kernel/service_thread.cpp
+++ b/src/core/hle/kernel/service_thread.cpp
@@ -40,7 +40,6 @@ private:
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;
@@ -180,39 +179,17 @@ ServiceThread::Impl::~Impl() {
// Close thread.
m_thread->Close();
-
- // Close process.
- m_process->Close();
}
ServiceThread::Impl::Impl(KernelCore& kernel_, const std::string& service_name)
: kernel{kernel_}, m_service_name{service_name} {
- // Initialize process.
- m_process = KProcess::Create(kernel);
- KProcess::Initialize(m_process, kernel.System(), service_name,
- KProcess::ProcessType::KernelInternal, kernel.GetSystemResourceLimit());
-
- // Reserve a new event from the process resource limit
- KScopedResourceReservation event_reservation(m_process, LimitableResource::EventCountMax);
- ASSERT(event_reservation.Succeeded());
-
// Initialize event.
m_wakeup_event = KEvent::Create(kernel);
- m_wakeup_event->Initialize(m_process);
-
- // Commit the event reservation.
- event_reservation.Commit();
-
- // Reserve a new thread from the process resource limit
- KScopedResourceReservation thread_reservation(m_process, LimitableResource::ThreadCountMax);
- ASSERT(thread_reservation.Succeeded());
+ m_wakeup_event->Initialize(nullptr);
// Initialize thread.
m_thread = KThread::Create(kernel);
- ASSERT(KThread::InitializeDummyThread(m_thread, m_process).IsSuccess());
-
- // Commit the thread reservation.
- thread_reservation.Commit();
+ ASSERT(KThread::InitializeDummyThread(m_thread, nullptr).IsSuccess());
// Start thread.
m_host_thread = std::jthread([this] { LoopProcess(); });