kennel/process: move process list to kernel instance

This commit is contained in:
Weiyi Wang 2018-10-17 14:06:47 -04:00
parent 4238754d8c
commit d9342622b0
5 changed files with 9 additions and 15 deletions

View File

@ -7,6 +7,7 @@
#include <atomic>
#include <memory>
#include <string>
#include <vector>
#include <boost/smart_ptr/intrusive_ptr.hpp>
#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<Process> GetProcessById(u32 process_id) const;
private:
std::unique_ptr<ResourceLimitList> resource_limits;
std::atomic<u32> 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<SharedPtr<Process>> process_list;
};
} // namespace Kernel

View File

@ -17,9 +17,6 @@
namespace Kernel {
// Lists all processes that exist in the current session.
static std::vector<SharedPtr<Process>> process_list;
SharedPtr<CodeSet> KernelSystem::CreateCodeSet(std::string name, u64 program_id) {
SharedPtr<CodeSet> 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<Process> GetProcessById(u32 process_id) {
SharedPtr<Process> KernelSystem::GetProcessById(u32 process_id) const {
auto itr = std::find_if(
process_list.begin(), process_list.end(),
[&](const SharedPtr<Process>& process) { return process->process_id == process_id; });

View File

@ -198,10 +198,5 @@ private:
KernelSystem& kernel;
};
void ClearProcessList();
/// Retrieves a process from the current list of processes.
SharedPtr<Process> GetProcessById(u32 process_id);
extern SharedPtr<Process> g_current_process;
} // namespace Kernel

View File

@ -516,7 +516,6 @@ void ThreadingShutdown() {
}
thread_list.clear();
ready_queue.clear();
ClearProcessList();
}
const std::vector<SharedPtr<Thread>>& GetThreadList() {

View File

@ -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);