summaryrefslogtreecommitdiff
path: root/kernel/task.c
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-12-01 23:33:31 +0100
committerMichal Idziorek <m.i@gmx.at>2014-12-01 23:33:31 +0100
commitf20db37ca17245d5d20302a1ac1da347de5c3607 (patch)
treece0712176387f4555cf290615b71cdd1c935557d /kernel/task.c
parentd8331335ff1720ce28eba45afe1a02814b38b033 (diff)
very buggy fork, execve and exit
Diffstat (limited to 'kernel/task.c')
-rw-r--r--kernel/task.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/kernel/task.c b/kernel/task.c
index 1780b77..6ea9b79 100644
--- a/kernel/task.c
+++ b/kernel/task.c
@@ -76,10 +76,31 @@ uint32_t task_switch_next(uint32_t oldesp)
}
+//TODO: free vmem too!
+uint32_t task_exit(uint32_t oldesp)
+{
+ task_list[current_task].active=false;
+
+ for(int i=0;i<MAX_TASKS;i++)
+ {
+ int pid=(current_task+1+i)%MAX_TASKS; // schedule round robin style
+
+ if(task_list[pid].active)
+ {
+ // log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"switch from %d to pid: %d (0x%08X) vmem: %d ", current_task,pid,task_list[pid].esp,task_list[pid].vmem);
+ current_task=pid;
+
+ vmem_set_dir(task_list[pid].vmem);
+ return task_list[pid].esp;
+ }
+
+ }
+}
uint32_t task_fork(uint32_t oldesp)
{
- return add_task(oldesp,vmem_new_space_dir());
+ int pid=add_task(oldesp,vmem_new_space_dir(task_list[current_task].vmem));
+ return pid;
}
// init task (root of all other tasks / processes) //