From f30c9803f05e90087e367953aa142275f8688f61 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 26 Apr 2020 23:23:42 +0200 Subject: Awesome new multitasking system and scheduler --- src/kernel/tasks/process.h | 71 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/kernel/tasks/process.h (limited to 'src/kernel/tasks/process.h') diff --git a/src/kernel/tasks/process.h b/src/kernel/tasks/process.h new file mode 100644 index 0000000..df0f51f --- /dev/null +++ b/src/kernel/tasks/process.h @@ -0,0 +1,71 @@ +#ifndef MELVIX_PROCESS_H +#define MELVIX_PROCESS_H + +#include +#include +#include + +struct mmap { + uint32_t text; + uint32_t bss; + uint32_t data; + uint32_t stack; +}; + +struct process { + struct page_directory *cr3; + struct regs registers; + + uint32_t pid; + uint32_t gid; + char *name; + + int state; + int thread; + + uint32_t stdint; + uint32_t stdout; + uint32_t stderr; + + uint32_t brk; + uint32_t handlers[6]; + + struct process *parent; + struct process *next; +}; + +void process_kill(uint32_t pid); + +uint32_t process_spawn(struct process *process); + +void process_suspend(uint32_t pid); +void process_wake(uint32_t pid); +uint32_t process_child(struct process *process, uint32_t pid); +uint32_t process_fork(uint32_t pid); + +int process_wait_gid(uint32_t gid, int *status); +int process_wait_pid(uint32_t pid, int *status); + +struct process *process_from_pid(uint32_t pid); + +void process_init(struct process *proc); + +struct process *process_make_new(); + +extern struct process *current_proc; + +extern uint32_t stack_hold; + +#define PID_NOT_FOUND ((struct process *)0xFFFFFFFF) + +#define PROC_RUNNING 0 +#define PROC_ASLEEP 1 + +#define PROC_THREAD 0 +#define PROC_PROC 1 +#define PROC_ROOT 2 + +#define WAIT_ERROR (-1) +#define WAIT_OKAY 0 + +#endif \ No newline at end of file -- cgit v1.2.3