// http://hosted.cjmovie.net/TutMultitask.htm // // #include "kernel.h" #include "lib/logger/log.h" // logger facilities #include "lib/buffer/ringbuffer.h" #include "mem.h" #include "timer.h" #include "console.h" #include "x86.h" #include "syscalls.h" #include "fs/fs.h" #include "fs/ext2.h" #define FOOLOS_MODULE_NAME "task" #define MAX_TASKS 10 static volatile int current_task=-1; static volatile struct task_list_struct { int parent; 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]; int add_task(uint32_t esp, uint32_t vmem) { for(int i=0;i [%d]", current_task, pid); return pid; } // init task (root of all other tasks / processes) // 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; static char *argv[]={"/bin/foolshell",NULL}; static char *env[]={"PATH=/bin","PWD=/home/miguel","PS1=$ ",NULL}; syscall_execve("/bin/init",argv,env); } int task_get_current_pid() { return current_task; }