[zion/glacier] Move RefPtr to glacier.
This commit is contained in:
parent
8bcb574677
commit
e1af79b975
26 changed files with 130 additions and 106 deletions
|
|
@ -7,7 +7,7 @@ void ProcessManager::Init() {
|
|||
gProcMan->InsertProcess(Process::RootProcess());
|
||||
}
|
||||
|
||||
void ProcessManager::InsertProcess(const RefPtr<Process>& proc) {
|
||||
void ProcessManager::InsertProcess(const glcr::RefPtr<Process>& proc) {
|
||||
proc_list_.PushBack(proc);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/memory/ref_ptr.h>
|
||||
|
||||
#include "lib/linked_list.h"
|
||||
#include "lib/ref_ptr.h"
|
||||
#include "object/process.h"
|
||||
|
||||
class ProcessManager {
|
||||
|
|
@ -10,14 +11,14 @@ class ProcessManager {
|
|||
// and stores it in the global variable.
|
||||
static void Init();
|
||||
|
||||
void InsertProcess(const RefPtr<Process>& proc);
|
||||
void InsertProcess(const glcr::RefPtr<Process>& proc);
|
||||
Process& FromId(uint64_t id);
|
||||
|
||||
void DumpProcessStates();
|
||||
|
||||
private:
|
||||
// TODO: This should be a hashmap.
|
||||
LinkedList<RefPtr<Process>> proc_list_;
|
||||
LinkedList<glcr::RefPtr<Process>> proc_list_;
|
||||
};
|
||||
|
||||
extern ProcessManager* gProcMan;
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ void Scheduler::Preempt() {
|
|||
return;
|
||||
}
|
||||
|
||||
RefPtr<Thread> prev = current_thread_;
|
||||
glcr::RefPtr<Thread> prev = current_thread_;
|
||||
prev->SetState(Thread::RUNNABLE);
|
||||
current_thread_ = runnable_threads_.CycleFront(prev);
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ void Scheduler::Yield() {
|
|||
}
|
||||
asm volatile("cli");
|
||||
|
||||
RefPtr<Thread> prev = current_thread_;
|
||||
glcr::RefPtr<Thread> prev = current_thread_;
|
||||
if (prev == sleep_thread_) {
|
||||
if (runnable_threads_.size() == 0) {
|
||||
panic("Sleep thread yielded without next.");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/memory/ref_ptr.h>
|
||||
|
||||
#include "object/process.h"
|
||||
#include "object/thread.h"
|
||||
|
||||
|
|
@ -13,9 +15,9 @@ class Scheduler {
|
|||
void Enable() { enabled_ = true; }
|
||||
|
||||
Process& CurrentProcess() { return current_thread_->process(); }
|
||||
RefPtr<Thread> CurrentThread() { return current_thread_; }
|
||||
glcr::RefPtr<Thread> CurrentThread() { return current_thread_; }
|
||||
|
||||
void Enqueue(const RefPtr<Thread>& thread) {
|
||||
void Enqueue(const glcr::RefPtr<Thread>& thread) {
|
||||
runnable_threads_.PushBack(thread);
|
||||
}
|
||||
|
||||
|
|
@ -25,10 +27,10 @@ class Scheduler {
|
|||
private:
|
||||
bool enabled_ = false;
|
||||
|
||||
RefPtr<Thread> current_thread_;
|
||||
LinkedList<RefPtr<Thread>> runnable_threads_;
|
||||
glcr::RefPtr<Thread> current_thread_;
|
||||
LinkedList<glcr::RefPtr<Thread>> runnable_threads_;
|
||||
|
||||
RefPtr<Thread> sleep_thread_;
|
||||
glcr::RefPtr<Thread> sleep_thread_;
|
||||
|
||||
Scheduler();
|
||||
void SwapToCurrent(Thread& prev);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue