From d9342622b031f6ce9721e9560971769f2dd941ec Mon Sep 17 00:00:00 2001 From: Weiyi Wang Date: Wed, 17 Oct 2018 14:06:47 -0400 Subject: [PATCH] kennel/process: move process list to kernel instance --- src/core/hle/kernel/kernel.h | 7 +++++++ src/core/hle/kernel/process.cpp | 9 +-------- src/core/hle/kernel/process.h | 5 ----- src/core/hle/kernel/thread.cpp | 1 - src/core/hle/service/fs/fs_user.cpp | 2 +- 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 015fbe87f..d3907a382 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "common/common_types.h" #include "core/hle/result.h" @@ -180,6 +181,9 @@ public: u32 GenerateObjectID(); + /// Retrieves a process from the current list of processes. + SharedPtr GetProcessById(u32 process_id) const; + private: std::unique_ptr resource_limits; std::atomic next_object_id{0}; @@ -187,6 +191,9 @@ private: // TODO(Subv): Start the process ids from 10 for now, as lower PIDs are // reserved for low-level services u32 next_process_id = 10; + + // Lists all processes that exist in the current session. + std::vector> process_list; }; } // namespace Kernel diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 7f089a4c4..23a4684a6 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp @@ -17,9 +17,6 @@ namespace Kernel { -// Lists all processes that exist in the current session. -static std::vector> process_list; - SharedPtr KernelSystem::CreateCodeSet(std::string name, u64 program_id) { SharedPtr codeset(new CodeSet(*this)); @@ -306,11 +303,7 @@ ResultCode Process::LinearFree(VAddr target, u32 size) { Kernel::Process::Process(KernelSystem& kernel) : Object(kernel), kernel(kernel) {} Kernel::Process::~Process() {} -void ClearProcessList() { - process_list.clear(); -} - -SharedPtr GetProcessById(u32 process_id) { +SharedPtr KernelSystem::GetProcessById(u32 process_id) const { auto itr = std::find_if( process_list.begin(), process_list.end(), [&](const SharedPtr& process) { return process->process_id == process_id; }); diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 70be04ff5..89ce9bf8a 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -198,10 +198,5 @@ private: KernelSystem& kernel; }; -void ClearProcessList(); - -/// Retrieves a process from the current list of processes. -SharedPtr GetProcessById(u32 process_id); - extern SharedPtr g_current_process; } // namespace Kernel diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 6844e76d5..99d9df133 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -516,7 +516,6 @@ void ThreadingShutdown() { } thread_list.clear(); ready_queue.clear(); - ClearProcessList(); } const std::vector>& GetThreadList() { diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index 7b1316e48..f9b883fe7 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -619,7 +619,7 @@ void FS_USER::GetProgramLaunchInfo(Kernel::HLERequestContext& ctx) { // TODO(Subv): The real FS service manages its own process list and only checks the processes // that were registered with the 'fs:REG' service. - auto process = Kernel::GetProcessById(process_id); + auto process = system.Kernel().GetProcessById(process_id); IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);