1 #ifndef __LUNAIX_PROCESS_H
2 #define __LUNAIX_PROCESS_H
5 #include <arch/x86/interrupts.h>
6 #include <lunaix/mm/mm.h>
7 #include <lunaix/types.h>
8 #include <lunaix/clock.h>
9 #include <lunaix/timer.h>
11 // 虽然内核不是进程,但为了区分,这里使用Pid=-1来指代内核。这主要是方便物理页所有权检查。
14 #define PROC_STOPPED 0
15 #define PROC_RUNNING 1
16 #define PROC_TERMNAT 2
17 #define PROC_DESTROY 4
18 #define PROC_BLOCKED 8
19 #define PROC_CREATED 16
21 #define PROC_TERMMASK 0x6
25 heap_context_t u_heap;
26 struct mm_region* regions;
31 struct proc_info* parent;
33 struct llist_header siblings;
34 struct llist_header children;
41 struct lx_timer* timer;
44 extern volatile struct proc_info* __current;
49 void init_proc(struct proc_info *pcb);
52 * @brief 向系统发布一个进程,使其可以被调度。
56 void push_process(struct proc_info* process);
58 pid_t destroy_process(pid_t pid);
60 void setup_proc_mem(struct proc_info* proc, uintptr_t kstack_from);
63 * @brief 复制当前进程(LunaixOS的类 fork (unix) 实现)
69 * @brief 创建新进程(LunaixOS的类 CreateProcess (Windows) 实现)
78 void terminate_proc(int exit_code);
80 int orphaned_proc(pid_t pid);
82 struct proc_info* get_process(pid_t pid);
84 #endif /* __LUNAIX_PROCESS_H */