1 #ifndef __LUNAIX_PROCESS_H
2 #define __LUNAIX_PROCESS_H
4 #include <arch/x86/interrupts.h>
5 #include <lunaix/clock.h>
6 #include <lunaix/mm/mm.h>
7 #include <lunaix/signal.h>
8 #include <lunaix/timer.h>
9 #include <lunaix/types.h>
12 // 虽然内核不是进程,但为了区分,这里使用Pid=-1来指代内核。这主要是方便物理页所有权检查。
15 #define PROC_STOPPED 0
16 #define PROC_RUNNING 1
17 #define PROC_TERMNAT 2
18 #define PROC_DESTROY 4
19 #define PROC_BLOCKED 8
20 #define PROC_CREATED 16
22 #define PROC_TERMMASK 0x6
24 #define PROC_FINPAUSE 1
28 heap_context_t u_heap;
29 struct mm_region regions;
36 isr_param prev_context;
39 #define PROC_SIG_SIZE sizeof(struct proc_sig) // size=84
44 Any change to *critical section*, including layout, size
45 must be reflected in kernel/asm/x86/interrupt.S to avoid
49 /* ---- critical section start ---- */
52 struct proc_info* parent;
53 isr_param intr_ctx; // size=76
57 /* ---- critical section end ---- */
59 struct llist_header siblings;
60 struct llist_header children;
61 struct llist_header grp_member;
70 void* sig_handler[_SIG_NUM];
72 struct lx_timer* timer;
75 extern volatile struct proc_info* __current;
78 * @brief 分配并初始化一个进程控制块
80 * @return struct proc_info*
91 init_proc_user_space(struct proc_info* pcb);
94 * @brief 向系统发布一个进程,使其可以被调度。
99 commit_process(struct proc_info* process);
102 destroy_process(pid_t pid);
105 setup_proc_mem(struct proc_info* proc, uintptr_t kstack_from);
108 * @brief 复制当前进程(LunaixOS的类 fork (unix) 实现)
115 * @brief 创建新进程(LunaixOS的类 CreateProcess (Windows) 实现)
126 terminate_proc(int exit_code);
129 orphaned_proc(pid_t pid);
132 get_process(pid_t pid);
134 #endif /* __LUNAIX_PROCESS_H */