From c2c03f41e078481921bad82487eded0fc51ebb59 Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Tue, 2 Dec 2014 01:02:49 +0100 Subject: further work on fork and friends --- kernel/syscalls.c | 20 --------------- kernel/task.c | 77 ++++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 57 insertions(+), 40 deletions(-) (limited to 'kernel') diff --git a/kernel/syscalls.c b/kernel/syscalls.c index 41d77ec..44b04bd 100644 --- a/kernel/syscalls.c +++ b/kernel/syscalls.c @@ -120,15 +120,6 @@ int syscall_readdir(const char *name,fs_dirent *dirs,int max) return fs_readdir(name,dirs,max); } -int syscall_wait(int *wait, int none1, int none2) -{ - #ifdef LOG_SYSCALLS - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"[%d] wait ",task_get_current_pid()); - #endif - - panic(FOOLOS_MODULE_NAME,"unhandled syscall"); -} - int syscall_execve(char *name, char **argv1, char **env1) { char *argv[]={"/bin/foolshell",NULL}; @@ -221,17 +212,6 @@ uint32_t syscall_sbrk(int incr, int none1, int none2) } -int syscall_exit(int ret, char **env, int none2) -{ - #ifdef LOG_SYSCALLS - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"exit (ret=%d) (env=0x%08X)", ret, env); - #endif - - panic(FOOLOS_MODULE_NAME,"exit not supported yet" ); - -} - - // stat, fstat, lstat int syscall_stat(const char *path, struct stat *st,int none) { diff --git a/kernel/task.c b/kernel/task.c index 6ea9b79..ac54dbe 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -17,7 +17,7 @@ #define MAX_TASKS 10 -static volatile int current_task=-2; +static volatile int current_task=-1; static volatile struct task_list_struct { @@ -25,6 +25,8 @@ static volatile struct task_list_struct bool active; uint32_t esp; // stack pointer of the task; uint32_t vmem; // number of virtual memory table to switch to + bool waiting; + bool skipwait; }volatile task_list[MAX_TASKS]; @@ -40,6 +42,8 @@ int add_task(uint32_t esp, uint32_t vmem) task_list[i].vmem=vmem; task_list[i].esp=esp; task_list[i].active=true; + task_list[i].waiting=false; + task_list[i].skipwait=false; return i; } @@ -48,22 +52,19 @@ int add_task(uint32_t esp, uint32_t vmem) panic(FOOLOS_MODULE_NAME,"out of task slots!"); } -// this gets called by our clock interrupt regularly! -uint32_t task_switch_next(uint32_t oldesp) +uint32_t my_scheduler(uint32_t oldesp) { - timer_tick(); - - if(current_task==-2)return oldesp; - task_list[current_task].esp=oldesp; - + for(int i=0;i [%d]", current_task, pid); return pid; } @@ -107,7 +142,9 @@ uint32_t task_fork(uint32_t oldesp) void task_init() { // this is our main task on slot 0 + task_list[0].parent=0; task_list[0].active=true; + task_list[0].waiting=false; task_list[0].vmem=0; task_list[0].esp = 0; // will be set by next task_switch_next() call. current_task=0; -- cgit v1.2.3