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
26 heap_context_t u_heap;
27 struct mm_region* regions;
34 isr_param prev_context;
37 #define PROC_SIG_SIZE sizeof(struct proc_sig) // size=84
42 Any change to *critical section*, including layout, size
43 must be reflected in kernel/asm/x86/interrupt.S to avoid
47 /* ---- critical section start ---- */
50 struct proc_info* parent;
51 isr_param intr_ctx; // size=76
55 /* ---- critical section end ---- */
57 struct llist_header siblings;
58 struct llist_header children;
59 struct llist_header grp_member;
67 void* sig_handler[_SIG_NUM];
69 struct lx_timer* timer;
72 extern volatile struct proc_info* __current;
78 init_proc(struct proc_info* pcb);
81 * @brief 向系统发布一个进程,使其可以被调度。
86 push_process(struct proc_info* process);
89 destroy_process(pid_t pid);
92 setup_proc_mem(struct proc_info* proc, uintptr_t kstack_from);
95 * @brief 复制当前进程(LunaixOS的类 fork (unix) 实现)
102 * @brief 创建新进程(LunaixOS的类 CreateProcess (Windows) 实现)
113 terminate_proc(int exit_code);
116 orphaned_proc(pid_t pid);
119 get_process(pid_t pid);
121 #endif /* __LUNAIX_PROCESS_H */