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
fix: corrected time conversion on alarm/sleep syscall
[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 a8ac5d84c19e85aa48aa15341c07c7957a361526..10dc5ec6513a90def740f1b2a82db41b1ca3f7ee 100644
(file)
--- a/
lunaix-os/includes/lunaix/process.h
+++ b/
lunaix-os/includes/lunaix/process.h
@@
-1,7
+1,6
@@
#ifndef __LUNAIX_PROCESS_H
#define __LUNAIX_PROCESS_H
#ifndef __LUNAIX_PROCESS_H
#define __LUNAIX_PROCESS_H
-#include <arch/x86/interrupts.h>
#include <lunaix/clock.h>
#include <lunaix/ds/waitq.h>
#include <lunaix/fs.h>
#include <lunaix/clock.h>
#include <lunaix/ds/waitq.h>
#include <lunaix/fs.h>
@@
-11,6
+10,7
@@
#include <lunaix/timer.h>
#include <lunaix/types.h>
#include <stdint.h>
#include <lunaix/timer.h>
#include <lunaix/types.h>
#include <stdint.h>
+#include <sys/interrupts.h>
// 虽然内核不是进程,但为了区分,这里使用Pid=-1来指代内核。这主要是方便物理页所有权检查。
#define KERNEL_PID -1
// 虽然内核不是进程,但为了区分,这里使用Pid=-1来指代内核。这主要是方便物理页所有权检查。
#define KERNEL_PID -1
@@
-41,17
+41,9
@@
#define PS_GrBP (PS_PAUSED | PS_BLOCKED)
#define PS_GrDT (PS_TERMNAT | PS_DESTROY)
#define PS_GrBP (PS_PAUSED | PS_BLOCKED)
#define PS_GrDT (PS_TERMNAT | PS_DESTROY)
-#define PROC_TERMINATED(state) ((state)&PS_GrDT)
-#define PROC_HANGED(state) ((state)&PS_BLOCKED)
-#define PROC_RUNNABLE(state) ((state)&PS_PAUSED)
-
-#define PROC_FINPAUSE 1
-
-struct proc_sigstate
-{
- isr_param proc_regs;
- char fxstate[512] __attribute__((aligned(16)));
-};
+#define proc_terminated(proc) (((proc)->state) & PS_GrDT)
+#define proc_hanged(proc) (((proc)->state) & PS_BLOCKED)
+#define proc_runnable(proc) (((proc)->state) & PS_PAUSED)
struct sigact
{
struct sigact
{
@@
-75,25
+67,24
@@
struct proc_sig
int sig_num;
void* sigact;
void* sighand;
int sig_num;
void* sigact;
void* sighand;
-
struct proc_sigstate prev_context
;
+
isr_param* saved_ictx
;
} __attribute__((packed));
struct proc_info
{
/*
Any change to *critical section*, including layout, size
} __attribute__((packed));
struct proc_info
{
/*
Any change to *critical section*, including layout, size
- must be reflected in
kernel/asm/x86/interrupt.S
to avoid
+ must be reflected in
arch/i386/interrupt.S.inc
to avoid
disaster!
*/
/* ---- critical section start ---- */
disaster!
*/
/* ---- critical section start ---- */
- 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
+ pid_t pid;
+ struct proc_info* parent;
+ isr_param* intr_ctx;
+ ptr_t ustack_top;
+ ptr_t page_table;
/* ---- critical section end ---- */
/* ---- critical section end ---- */
@@
-115,7
+106,6
@@
struct proc_info
u8_t state;
int32_t exit_code;
int32_t k_status;
u8_t state;
int32_t exit_code;
int32_t k_status;
- int flags;
struct sighail sigctx;
struct v_fdtable* fdtable;
struct v_dnode* cwd;
struct sighail sigctx;
struct v_fdtable* fdtable;
struct v_dnode* cwd;
@@
-170,7
+160,7
@@
pid_t
destroy_process(pid_t pid);
void
destroy_process(pid_t pid);
void
-
setup_proc_mem
(struct proc_info* proc, ptr_t kstack_from);
+
copy_kernel_stack
(struct proc_info* proc, ptr_t kstack_from);
/**
* @brief 复制当前进程(LunaixOS的类 fork (unix) 实现)
/**
* @brief 复制当前进程(LunaixOS的类 fork (unix) 实现)
@@
-202,4
+192,21
@@
get_process(pid_t pid);
void
proc_setsignal(struct proc_info* proc, int signum);
void
proc_setsignal(struct proc_info* proc, int signum);
+void
+proc_clear_signal(struct proc_info* proc);
+
+// enable interrupt upon transfer
+#define TRANSFER_IE 1
+
+/**
+ * @brief Setup process initial context, used to initiate first switch
+ *
+ * @param proc
+ * @param stop
+ * @param target
+ * @param flags
+ */
+void
+proc_init_transfer(struct proc_info* proc, ptr_t stop, ptr_t target, int flags);
+
#endif /* __LUNAIX_PROCESS_H */
#endif /* __LUNAIX_PROCESS_H */