From e0449c5adc89eec9f378cb40a56762bf314a80ea Mon Sep 17 00:00:00 2001 From: Miguel Date: Sat, 15 Sep 2018 23:46:04 +0200 Subject: scheduler / sleep process --- kernel/scheduler.c | 75 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 14 deletions(-) (limited to 'kernel/scheduler.c') diff --git a/kernel/scheduler.c b/kernel/scheduler.c index ad6b370..b5d1b34 100644 --- a/kernel/scheduler.c +++ b/kernel/scheduler.c @@ -73,25 +73,36 @@ volatile void scheduler_init(uint32_t cpu, void *dir) task_list[cpu][0].pid=nextPID(); task_list[cpu][0].active=true; task_list[cpu][0].syscall=false; - task_list[cpu][0].thread=false; + task_list[cpu][1].thread=false; task_list[cpu][0].vmem=dir; task_list[cpu][0].esp = VMEM_CPU_STACK_TOP-0x200; task_list[cpu][0].esp0 = 0; // esp0 not needed by kernel space tasks - task_pusha(task_list[cpu][0].esp); - - // this is our main kernel task at slot 0 (per cpu) + // this will go to userspace task_list[cpu][1].parent=0; task_list[cpu][1].pid=nextPID(); task_list[cpu][1].active=true; - task_list[cpu][0].thread=false; + task_list[cpu][1].thread=false; task_list[cpu][1].syscall=false; task_list[cpu][1].vmem=dir; task_list[cpu][1].esp = kballoc(4)+4*4096-0x200; // 4 pages stack task_list[cpu][1].esp0 =kballoc(4)+4*4096; // esp0 not needed by kernel space tasks + + // sleeper + task_list[cpu][2].parent=0; + task_list[cpu][2].pid=nextPID(); + task_list[cpu][2].active=true; + task_list[cpu][2].thread=false; + task_list[cpu][2].syscall=false; + task_list[cpu][2].vmem=dir; + task_list[cpu][2].esp = kballoc(4)+4*4096-0x200; // 4 pages stack + task_list[cpu][2].esp0 =kballoc(4)+4*4096; // esp0 not needed by kernel space tasks + + // stacks task_pusha(task_list[cpu][0].esp); task_pusha(task_list[cpu][1].esp); + task_pusha(task_list[cpu][2].esp); } // @@ -104,7 +115,7 @@ volatile void scheduler_init(uint32_t cpu, void *dir) // // we need to return a NEW stack pointer where popa will get the registers the new task requires // -volatile uint32_t scheduler_run(uint32_t oldesp,uint32_t force_pid) +volatile uint32_t scheduler_run(uint32_t oldesp) { uint32_t cpu=smp_get(SMP_APIC_ID); uint32_t init=smp_get(SMP_SCHEDULER_INIT); @@ -117,6 +128,7 @@ volatile uint32_t scheduler_run(uint32_t oldesp,uint32_t force_pid) for(int i=0;i