git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refactor: keep in mind the stack layout is crucial. Move context switching & signal...
[lunaix-os.git]
/
lunaix-os
/
includes
/
lunaix
/
process.h
diff --git
a/lunaix-os/includes/lunaix/process.h
b/lunaix-os/includes/lunaix/process.h
index efa11666674b9602bdc07100d8bd6bc35fe2896b..0b743d39c3058fff0d1d61b702ff149ae3a67d78 100644
(file)
--- a/
lunaix-os/includes/lunaix/process.h
+++ b/
lunaix-os/includes/lunaix/process.h
@@
-1,74
+1,110
@@
#ifndef __LUNAIX_PROCESS_H
#define __LUNAIX_PROCESS_H
#ifndef __LUNAIX_PROCESS_H
#define __LUNAIX_PROCESS_H
-#include <stdint.h>
#include <arch/x86/interrupts.h>
#include <arch/x86/interrupts.h>
+#include <lunaix/clock.h>
#include <lunaix/mm/mm.h>
#include <lunaix/mm/mm.h>
+#include <lunaix/signal.h>
+#include <lunaix/timer.h>
#include <lunaix/types.h>
#include <lunaix/types.h>
-#include <
lunaix/clock
.h>
+#include <
stdint
.h>
// 虽然内核不是进程,但为了区分,这里使用Pid=-1来指代内核。这主要是方便物理页所有权检查。
#define KERNEL_PID -1
// 虽然内核不是进程,但为了区分,这里使用Pid=-1来指代内核。这主要是方便物理页所有权检查。
#define KERNEL_PID -1
-#define PROC_
CREAT
ED 0
+#define PROC_
STOPP
ED 0
#define PROC_RUNNING 1
#define PROC_RUNNING 1
-#define PROC_STOPPED 2
-#define PROC_TERMNAT 3
+#define PROC_TERMNAT 2
#define PROC_DESTROY 4
#define PROC_DESTROY 4
+#define PROC_BLOCKED 8
+#define PROC_CREATED 16
+#define PROC_TERMMASK 0x6
-struct proc_mm {
+struct proc_mm
+{
heap_context_t u_heap;
heap_context_t u_heap;
- struct mm_region* region;
+ struct mm_region* regions;
+};
+
+struct proc_sig
+{
+ void* signal_handler;
+ int sig_num;
+ isr_param prev_context;
};
};
-struct proc_info {
+#define PROC_SIG_SIZE sizeof(struct proc_sig) // size=84
+
+struct proc_info
+{
pid_t pid;
pid_t pid;
-
pid_t
parent;
- isr_param intr_ctx;
-
struct proc_mm mm
;
+
struct proc_info*
parent;
+ isr_param intr_ctx;
// size=76
+
uintptr_t ustack_top
;
void* page_table;
void* page_table;
+ struct llist_header siblings;
+ struct llist_header children;
+ struct llist_header grp_member;
+ struct proc_mm mm;
time_t created;
time_t created;
- time_t parent_created;
uint8_t state;
int32_t exit_code;
int32_t k_status;
uint8_t state;
int32_t exit_code;
int32_t k_status;
+ sigset_t sig_pending;
+ sigset_t sig_mask;
+ void* sig_handler[_SIG_NUM];
+ pid_t pgid;
+ struct lx_timer* timer;
};
};
-extern struct proc_info* __current;
+extern
volatile
struct proc_info* __current;
+pid_t
+alloc_pid();
-pid_t alloc_pid();
+void
+init_proc(struct proc_info* pcb);
/**
* @brief 向系统发布一个进程,使其可以被调度。
/**
* @brief 向系统发布一个进程,使其可以被调度。
- *
- * @param process
+ *
+ * @param process
*/
*/
-void push_process(struct proc_info* process);
+void
+push_process(struct proc_info* process);
-void destroy_process(pid_t pid);
+pid_t
+destroy_process(pid_t pid);
-void* dup_pagetable(pid_t pid);
+void
+setup_proc_mem(struct proc_info* proc, uintptr_t kstack_from);
/**
* @brief 复制当前进程(LunaixOS的类 fork (unix) 实现)
/**
* @brief 复制当前进程(LunaixOS的类 fork (unix) 实现)
- *
+ *
*/
*/
-void dup_proc();
+pid_t
+dup_proc();
/**
* @brief 创建新进程(LunaixOS的类 CreateProcess (Windows) 实现)
/**
* @brief 创建新进程(LunaixOS的类 CreateProcess (Windows) 实现)
- *
+ *
*/
*/
-void new_proc();
+void
+new_proc();
/**
* @brief 终止(退出)当前进程
/**
* @brief 终止(退出)当前进程
- *
+ *
*/
*/
-void terminate_process(int exit_code);
+void
+terminate_proc(int exit_code);
+
+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 */
#endif /* __LUNAIX_PROCESS_H */