kernel/process: move next_process_id to kernel instance

This commit is contained in:
Weiyi Wang 2018-10-17 13:47:42 -04:00
parent 129ca865b3
commit 4238754d8c
4 changed files with 6 additions and 8 deletions

View File

@ -23,9 +23,6 @@ KernelSystem::KernelSystem(u32 system_mode) {
resource_limits = std::make_unique<ResourceLimitList>(*this); resource_limits = std::make_unique<ResourceLimitList>(*this);
Kernel::ThreadingInit(); Kernel::ThreadingInit();
Kernel::TimersInit(); Kernel::TimersInit();
// TODO(Subv): Start the process ids from 10 for now, as lower PIDs are
// reserved for low-level services
Process::next_process_id = 10;
} }
/// Shutdown the kernel /// Shutdown the kernel

View File

@ -183,6 +183,10 @@ public:
private: private:
std::unique_ptr<ResourceLimitList> resource_limits; std::unique_ptr<ResourceLimitList> resource_limits;
std::atomic<u32> next_object_id{0}; std::atomic<u32> next_object_id{0};
// TODO(Subv): Start the process ids from 10 for now, as lower PIDs are
// reserved for low-level services
u32 next_process_id = 10;
}; };
} // namespace Kernel } // namespace Kernel

View File

@ -32,8 +32,6 @@ SharedPtr<CodeSet> KernelSystem::CreateCodeSet(std::string name, u64 program_id)
CodeSet::CodeSet(KernelSystem& kernel) : Object(kernel) {} CodeSet::CodeSet(KernelSystem& kernel) : Object(kernel) {}
CodeSet::~CodeSet() {} CodeSet::~CodeSet() {}
u32 Process::next_process_id;
SharedPtr<Process> KernelSystem::CreateProcess(SharedPtr<CodeSet> code_set) { SharedPtr<Process> KernelSystem::CreateProcess(SharedPtr<CodeSet> code_set) {
SharedPtr<Process> process(new Process(*this)); SharedPtr<Process> process(new Process(*this));
@ -41,6 +39,7 @@ SharedPtr<Process> KernelSystem::CreateProcess(SharedPtr<CodeSet> code_set) {
process->flags.raw = 0; process->flags.raw = 0;
process->flags.memory_region.Assign(MemoryRegion::APPLICATION); process->flags.memory_region.Assign(MemoryRegion::APPLICATION);
process->status = ProcessStatus::Created; process->status = ProcessStatus::Created;
process->process_id = ++next_process_id;
process_list.push_back(process); process_list.push_back(process);
return process; return process;

View File

@ -123,8 +123,6 @@ public:
return HANDLE_TYPE; return HANDLE_TYPE;
} }
static u32 next_process_id;
SharedPtr<CodeSet> codeset; SharedPtr<CodeSet> codeset;
/// Resource limit descriptor for this process /// Resource limit descriptor for this process
SharedPtr<ResourceLimit> resource_limit; SharedPtr<ResourceLimit> resource_limit;
@ -145,7 +143,7 @@ public:
ProcessStatus status; ProcessStatus status;
/// The id of this process /// The id of this process
u32 process_id = next_process_id++; u32 process_id;
/** /**
* Parses a list of kernel capability descriptors (as found in the ExHeader) and applies them * Parses a list of kernel capability descriptors (as found in the ExHeader) and applies them