From 4404fa9b3d98646f942e32146722a9d0a68edc13 Mon Sep 17 00:00:00 2001 From: Miguel Date: Thu, 23 Aug 2018 03:20:56 +0200 Subject: never ending struggle with forking --- kernel/scheduler.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'kernel/scheduler.c') 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() -- cgit v1.2.3