X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/088403ac98acf7991507715d29a282dcba222053..1b471813a2ba287c2ace9cf6c866f330c725b99c:/lunaix-os/includes/lunaix/process.h diff --git a/lunaix-os/includes/lunaix/process.h b/lunaix-os/includes/lunaix/process.h index 76ecacc..32b74df 100644 --- a/lunaix-os/includes/lunaix/process.h +++ b/lunaix-os/includes/lunaix/process.h @@ -1,12 +1,12 @@ #ifndef __LUNAIX_PROCESS_H #define __LUNAIX_PROCESS_H -#include #include -#include -#include #include +#include #include +#include +#include // 虽然内核不是进程,但为了区分,这里使用Pid=-1来指代内核。这主要是方便物理页所有权检查。 #define KERNEL_PID -1 @@ -20,65 +20,77 @@ #define PROC_TERMMASK 0x6 - -struct proc_mm { +struct proc_mm +{ heap_context_t u_heap; struct mm_region* regions; }; -struct proc_info { +struct proc_info +{ pid_t pid; struct proc_info* parent; isr_param intr_ctx; struct llist_header siblings; struct llist_header children; + struct llist_header grp_member; struct proc_mm mm; void* page_table; time_t created; uint8_t state; int32_t exit_code; int32_t k_status; + pid_t pgid; struct lx_timer* timer; }; extern volatile struct proc_info* __current; +pid_t +alloc_pid(); -pid_t alloc_pid(); - -void init_proc(struct proc_info *pcb); +void +init_proc(struct proc_info* pcb); /** * @brief 向系统发布一个进程,使其可以被调度。 - * - * @param process + * + * @param process */ -void push_process(struct proc_info* process); +void +push_process(struct proc_info* process); -pid_t destroy_process(pid_t pid); +pid_t +destroy_process(pid_t pid); -void setup_proc_mem(struct proc_info* proc, uintptr_t kstack_from); +void +setup_proc_mem(struct proc_info* proc, uintptr_t kstack_from); /** * @brief 复制当前进程(LunaixOS的类 fork (unix) 实现) - * + * */ -pid_t dup_proc(); +pid_t +dup_proc(); /** * @brief 创建新进程(LunaixOS的类 CreateProcess (Windows) 实现) - * + * */ -void new_proc(); +void +new_proc(); /** * @brief 终止(退出)当前进程 - * + * */ -void terminate_proc(int exit_code); +void +terminate_proc(int exit_code); -int orphaned_proc(pid_t pid); +int +orphaned_proc(pid_t pid); -struct proc_info* get_process(pid_t pid); +struct proc_info* +get_process(pid_t pid); #endif /* __LUNAIX_PROCESS_H */