From dbba25aa24f86c1f8c3a0589c82985840adc1b6b Mon Sep 17 00:00:00 2001 From: Richard Qin Date: Wed, 31 Dec 2025 18:00:55 +0800 Subject: dev:Refactor Memory Management and Process Management --- include/kernel/proc_def.h | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 include/kernel/proc_def.h (limited to 'include/kernel/proc_def.h') diff --git a/include/kernel/proc_def.h b/include/kernel/proc_def.h new file mode 100644 index 0000000..e5a2cbc --- /dev/null +++ b/include/kernel/proc_def.h @@ -0,0 +1,59 @@ +#pragma once +#include "common/types.h" + +struct cpu; +struct Trapframe; + +enum ProcState +{ + UNUSED, + USED, + SLEEPING, + RUNNABLE, + RUNNING, + ZOMBIE, +}; + +#define PRIO_MAX 0 +#define PRIO_MIN 3 +#define N_PRIO 4 + +// Context structure +struct Context +{ + uint64 ra; + uint64 sp; + uint64 s0; + uint64 s1; + uint64 s2; + uint64 s3; + uint64 s4; + uint64 s5; + uint64 s6; + uint64 s7; + uint64 s8; + uint64 s9; + uint64 s10; + uint64 s11; +}; + +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; + + struct Proc *next; + struct Proc *prev; + int priority; + int ticks; + struct cpu *cpu; +}; \ No newline at end of file -- cgit v1.2.3