2023-05-29 23:35:44 -07:00
|
|
|
#include "scheduler/process_manager.h"
|
|
|
|
|
2023-06-26 15:01:55 -07:00
|
|
|
#include "debug/debug.h"
|
|
|
|
|
2023-05-29 23:35:44 -07:00
|
|
|
ProcessManager* gProcMan = nullptr;
|
|
|
|
|
|
|
|
void ProcessManager::Init() {
|
|
|
|
gProcMan = new ProcessManager();
|
|
|
|
gProcMan->InsertProcess(Process::RootProcess());
|
|
|
|
}
|
|
|
|
|
2023-06-21 15:07:40 -07:00
|
|
|
void ProcessManager::InsertProcess(const glcr::RefPtr<Process>& proc) {
|
2023-05-29 23:35:44 -07:00
|
|
|
proc_list_.PushBack(proc);
|
|
|
|
}
|
|
|
|
|
|
|
|
Process& ProcessManager::FromId(uint64_t pid) {
|
2023-06-26 15:46:03 -07:00
|
|
|
if (pid >= proc_list_.size()) {
|
|
|
|
panic("Bad proc access %u, have %u processes", pid, proc_list_.size());
|
2023-05-29 23:35:44 -07:00
|
|
|
}
|
2023-06-26 15:46:03 -07:00
|
|
|
return *proc_list_[pid];
|
2023-05-29 23:35:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProcessManager::DumpProcessStates() {
|
|
|
|
dbgln("Process States: %u", proc_list_.size());
|
2023-06-26 15:46:03 -07:00
|
|
|
for (uint64_t i = 0; i < proc_list_.size(); i++) {
|
|
|
|
dbgln("%u: %u", proc_list_[i]->id(), proc_list_[i]->GetState());
|
2023-05-29 23:35:44 -07:00
|
|
|
}
|
|
|
|
}
|