Add a ProcessManager class to store Process objects.
Trying out a new method for exposing global objects directly via a variable.
This commit is contained in:
parent
b58186265e
commit
7fe6c24aa5
7 changed files with 66 additions and 23 deletions
34
zion/scheduler/process_manager.cpp
Normal file
34
zion/scheduler/process_manager.cpp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#include "scheduler/process_manager.h"
|
||||
|
||||
ProcessManager* gProcMan = nullptr;
|
||||
|
||||
void ProcessManager::Init() {
|
||||
gProcMan = new ProcessManager();
|
||||
gProcMan->InsertProcess(Process::RootProcess());
|
||||
}
|
||||
|
||||
void ProcessManager::InsertProcess(const SharedPtr<Process>& proc) {
|
||||
proc_list_.PushBack(proc);
|
||||
}
|
||||
|
||||
Process& ProcessManager::FromId(uint64_t pid) {
|
||||
auto iter = proc_list_.begin();
|
||||
while (iter != proc_list_.end()) {
|
||||
if (iter->id() == pid) {
|
||||
return **iter;
|
||||
}
|
||||
++iter;
|
||||
}
|
||||
|
||||
panic("Searching for invalid process id");
|
||||
return *((Process*)0);
|
||||
}
|
||||
|
||||
void ProcessManager::DumpProcessStates() {
|
||||
dbgln("Process States: %u", proc_list_.size());
|
||||
auto iter = proc_list_.begin();
|
||||
while (iter != proc_list_.end()) {
|
||||
dbgln("%u: %u", iter->id(), iter->GetState());
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue