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来指代内核。这主要是方便物理页所有权检查。
22 #define PROC_TERMINATED(state) (state & 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;
65 struct llist_header sleepers;
77 sigset_t sig_inprogress;
79 void* sig_handler[_SIG_NUM];
83 extern volatile struct proc_info* __current;
86 * @brief 分配并初始化一个进程控制块
88 * @return struct proc_info*
99 init_proc_user_space(struct proc_info* pcb);
102 * @brief 向系统发布一个进程,使其可以被调度。
107 commit_process(struct proc_info* process);
110 destroy_process(pid_t pid);
113 setup_proc_mem(struct proc_info* proc, uintptr_t kstack_from);
116 * @brief 复制当前进程(LunaixOS的类 fork (unix) 实现)
123 * @brief 创建新进程(LunaixOS的类 CreateProcess (Windows) 实现)
134 terminate_proc(int exit_code);
137 orphaned_proc(pid_t pid);
140 get_process(pid_t pid);
142 #endif /* __LUNAIX_PROCESS_H */