1 #ifndef __LUNAIX_PROCESS_H
2 #define __LUNAIX_PROCESS_H
4 #include <arch/x86/interrupts.h>
5 #include <lunaix/clock.h>
6 #include <lunaix/ds/waitq.h>
8 #include <lunaix/mm/mm.h>
9 #include <lunaix/signal.h>
10 #include <lunaix/timer.h>
11 #include <lunaix/types.h>
14 // 虽然内核不是进程,但为了区分,这里使用Pid=-1来指代内核。这主要是方便物理页所有权检查。
24 #define PROC_TERMINATED(state) (state & 0x6)
26 #define PROC_FINPAUSE 1
30 heap_context_t u_heap;
31 struct mm_region regions;
38 isr_param prev_context;
41 #define PROC_SIG_SIZE sizeof(struct proc_sig) // size=84
46 Any change to *critical section*, including layout, size
47 must be reflected in kernel/asm/x86/interrupt.S to avoid
51 /* ---- critical section start ---- */
54 struct proc_info* parent;
55 isr_param intr_ctx; // size=76
59 /* ---- critical section end ---- */
61 struct llist_header siblings;
62 struct llist_header children;
63 struct llist_header grp_member;
68 struct llist_header sleepers;
80 sigset_t sig_inprogress;
82 void* sig_handler[_SIG_NUM];
83 struct v_fdtable* fdtable;
88 extern volatile struct proc_info* __current;
91 * @brief 分配并初始化一个进程控制块
93 * @return struct proc_info*
104 init_proc_user_space(struct proc_info* pcb);
107 * @brief 向系统发布一个进程,使其可以被调度。
112 commit_process(struct proc_info* process);
115 destroy_process(pid_t pid);
118 setup_proc_mem(struct proc_info* proc, uintptr_t kstack_from);
121 * @brief 复制当前进程(LunaixOS的类 fork (unix) 实现)
128 * @brief 创建新进程(LunaixOS的类 CreateProcess (Windows) 实现)
139 terminate_proc(int exit_code);
142 orphaned_proc(pid_t pid);
145 get_process(pid_t pid);
147 #endif /* __LUNAIX_PROCESS_H */