diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2025-12-31 18:00:55 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2025-12-31 18:00:55 +0800 |
| commit | dbba25aa24f86c1f8c3a0589c82985840adc1b6b (patch) | |
| tree | 11d1d7ee552030d953db9f911d5af6e079291c47 /include/kernel/proc.h | |
| parent | 7759eef8cdac79028dd5b468bd9ce0cf1c12b162 (diff) | |
| download | lume-dbba25aa24f86c1f8c3a0589c82985840adc1b6b.tar.gz lume-dbba25aa24f86c1f8c3a0589c82985840adc1b6b.tar.xz | |
dev:Refactor Memory Management and Process Management
Diffstat (limited to 'include/kernel/proc.h')
| -rw-r--r-- | include/kernel/proc.h | 65 |
1 files changed, 1 insertions, 64 deletions
diff --git a/include/kernel/proc.h b/include/kernel/proc.h index e77fdc9..d63ccf7 100644 --- a/include/kernel/proc.h +++ b/include/kernel/proc.h @@ -1,71 +1,8 @@ #pragma once #include "common/types.h" -#include "kernel/trap.h" +#include "kernel/proc_def.h" #include "kernel/spinlock.h" -// Context structure, used for context switching -struct Context -{ - uint64 ra; - uint64 sp; - - // Callee-saved registers - uint64 s0; - uint64 s1; - uint64 s2; - uint64 s3; - uint64 s4; - uint64 s5; - uint64 s6; - uint64 s7; - uint64 s8; - uint64 s9; - uint64 s10; - uint64 s11; -}; - -// Process State Enumeration -enum ProcState -{ - UNUSED, - USED, - SLEEPING, - RUNNABLE, - RUNNING, - ZOMBIE, -}; - -// Process Control Block (PCB) -struct Proc -{ - struct Context context; - struct Trapframe *tf; - - uint64 *pagetable; - - enum ProcState state; - int pid; - - void *kstack; - char name[16]; - uint64 sz; - - struct Proc *parent; - void *chan; - int xstate; - - // Implement later -}; - -// CPU status structure -struct cpu -{ - struct Proc *proc; // Processes currently running on this CPU - struct Context context; // Save the scheduler context here - int noff; // Depth of push_off() - int intena; // Interrupt enable status before closing -}; - namespace ProcManager { void init(); |
