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