summaryrefslogtreecommitdiff
path: root/kernel/scheduler.c
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-08-23 03:20:56 +0200
committerMiguel <m.i@gmx.at>2018-08-23 03:20:56 +0200
commit4404fa9b3d98646f942e32146722a9d0a68edc13 (patch)
tree79e494ec81a462db0217fc763a7ddae1827c02bd /kernel/scheduler.c
parent98bf7b67543b36b6fe49f2b68c115ebeaf630603 (diff)
never ending struggle with forking
Diffstat (limited to 'kernel/scheduler.c')
-rw-r--r--kernel/scheduler.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/kernel/scheduler.c b/kernel/scheduler.c
index 5cc5508..540e72b 100644
--- a/kernel/scheduler.c
+++ b/kernel/scheduler.c
@@ -35,12 +35,23 @@ volatile int add_task(uint32_t esp, uint32_t vmem)
{
task_list[i].parent=current_task;
task_list[i].vmem=vmem;
- task_list[i].esp=esp;
+ task_list[i].esp = kballoc(4)+4*4096;
task_list[i].esp0 = kballoc(4)+4*4096;
task_list[i].active=true;
task_list[i].waiting=false;
task_list[i].skipwait=false;
task_list[i].brk=task_list[current_task].brk;
+
+ uint32_t *addi2=(uint32_t *)esp;
+ addi2+=14;
+
+ for(int x=0;x<15;x++)
+ {
+ task_list[i].esp-=4;
+ uint32_t *addi1=(uint32_t *)task_list[i].esp;
+ *addi1=*addi2;
+ addi2--;
+ }
return i;
}
}
@@ -168,17 +179,16 @@ volatile void scheduler_init(pdirectory *dir)
task_list[1].waiting=false;
task_list[1].vmem=dir;
task_list[1].esp = kballoc(4)+4*4096;
- task_list[1].esp0 = 0; // not needed by kernel space task
+ task_list[1].esp0 = 0; // not needed by kernel space tasks
- task_pusha(task_list[1].esp); // pusha but to alternative location
- task_pusha(task_list[0].esp); // pusha but to alternative location
+ task_pusha(task_list[1].esp);
+ task_pusha(task_list[0].esp);
// finally enable interrrupts so the scheduler is called (by timer)
x86_sti();
// loop until scheduler kicks in and reschedules us...
while(1);
-
}
volatile int task_get_current_pid()