X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/a5338b60e111972364a8bc6f07011c6defd213d2..45e1f8b055043e54be35462852ab6649d634da7c:/lunaix-os/includes/lunaix/process.h diff --git a/lunaix-os/includes/lunaix/process.h b/lunaix-os/includes/lunaix/process.h index 7c8c114..974907d 100644 --- a/lunaix-os/includes/lunaix/process.h +++ b/lunaix-os/includes/lunaix/process.h @@ -3,8 +3,10 @@ #include #include +#include #include #include +#include #include #include #include @@ -13,7 +15,7 @@ // 虽然内核不是进程,但为了区分,这里使用Pid=-1来指代内核。这主要是方便物理页所有权检查。 #define KERNEL_PID -1 -#define PS_STOPPED 0 +#define PS_READY 0 #define PS_RUNNING 1 #define PS_TERMNAT 2 #define PS_DESTROY 4 @@ -24,20 +26,18 @@ #define PROC_FINPAUSE 1 -struct proc_mm +struct proc_sigstate { - heap_context_t u_heap; - struct mm_region regions; + isr_param proc_regs; + char fxstate[512] __attribute__((aligned(16))); }; struct proc_sig { void* signal_handler; int sig_num; - isr_param prev_context; -}; - -#define PROC_SIG_SIZE sizeof(struct proc_sig) // size=84 + struct proc_sigstate prev_context; +} __attribute__((packed)); struct proc_info { @@ -49,17 +49,20 @@ struct proc_info /* ---- critical section start ---- */ - pid_t pid; - struct proc_info* parent; - isr_param intr_ctx; // size=76 - uintptr_t ustack_top; - void* page_table; + pid_t pid; // offset = 0 + struct proc_info* parent; // offset = 4 + isr_param intr_ctx; // offset = 8 + ptr_t ustack_top; // offset = 84 -> 56 -> 60 + ptr_t page_table; // offset = 88 -> 60 -> 64 + void* fxstate; // offset = 92 -> 64 -> 68 /* ---- critical section end ---- */ + struct llist_header tasks; struct llist_header siblings; struct llist_header children; struct llist_header grp_member; + waitq_t waitqueue; struct { @@ -70,7 +73,7 @@ struct proc_info struct proc_mm mm; time_t created; - uint8_t state; + u8_t state; int32_t exit_code; int32_t k_status; sigset_t sig_pending; @@ -79,11 +82,18 @@ struct proc_info int flags; void* sig_handler[_SIG_NUM]; struct v_fdtable* fdtable; + struct v_dnode* cwd; pid_t pgid; }; extern volatile struct proc_info* __current; +static inline void +block_current() +{ + __current->state = PS_BLOCKED; +} + /** * @brief 分配并初始化一个进程控制块 * @@ -112,7 +122,7 @@ pid_t destroy_process(pid_t pid); void -setup_proc_mem(struct proc_info* proc, uintptr_t kstack_from); +setup_proc_mem(struct proc_info* proc, ptr_t kstack_from); /** * @brief 复制当前进程(LunaixOS的类 fork (unix) 实现)