2023-05-29 23:35:44 -07:00
|
|
|
#pragma once
|
|
|
|
|
2023-06-26 15:46:03 -07:00
|
|
|
#include <glacier/container/vector.h>
|
2023-06-21 15:07:40 -07:00
|
|
|
#include <glacier/memory/ref_ptr.h>
|
|
|
|
|
2023-06-06 20:18:53 -07:00
|
|
|
#include "object/process.h"
|
2023-11-24 15:04:03 -08:00
|
|
|
#include "scheduler/cleanup.h"
|
2023-05-29 23:35:44 -07:00
|
|
|
|
|
|
|
class ProcessManager {
|
|
|
|
public:
|
|
|
|
// Initializes the ProcessManager
|
|
|
|
// and stores it in the global variable.
|
|
|
|
static void Init();
|
|
|
|
|
2023-06-21 15:07:40 -07:00
|
|
|
void InsertProcess(const glcr::RefPtr<Process>& proc);
|
2023-11-16 23:03:27 -08:00
|
|
|
void RemoveProcess(uint64_t id);
|
|
|
|
|
2023-05-29 23:35:44 -07:00
|
|
|
Process& FromId(uint64_t id);
|
|
|
|
|
2023-11-24 15:04:03 -08:00
|
|
|
void InitCleanup();
|
|
|
|
|
|
|
|
void CleanupProcess(uint64_t pid);
|
|
|
|
void CleanupThread(glcr::RefPtr<Thread> thread);
|
|
|
|
|
2023-05-29 23:35:44 -07:00
|
|
|
private:
|
2023-11-16 22:17:11 -08:00
|
|
|
glcr::HashMap<uint64_t, glcr::RefPtr<Process>> proc_map_;
|
2023-11-24 15:04:03 -08:00
|
|
|
ProcessCleanup cleanup;
|
2023-05-29 23:35:44 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
extern ProcessManager* gProcMan;
|