From 6c926175afbf1f9ec2715fb007acc28588b36c4a Mon Sep 17 00:00:00 2001 From: Miguel Date: Tue, 21 Aug 2018 17:54:28 +0200 Subject: cleaning up multitasking --- kernel/task.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 6 deletions(-) (limited to 'kernel/task.c') diff --git a/kernel/task.c b/kernel/task.c index c281821..395c196 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -45,7 +45,6 @@ volatile int add_task(uint32_t esp, uint32_t vmem) task_list[i].waiting=false; task_list[i].skipwait=false; task_list[i].brk=task_list[current_task].brk; - return i; } } @@ -53,9 +52,29 @@ volatile int add_task(uint32_t esp, uint32_t vmem) panic(FOOLOS_MODULE_NAME,"out of task slots!"); } +// +// REMEMBER WE ARE INSIDE AN INTERRUPT HERE - DON'T WASTE TIME! +// +// oldesp - is the adress of the stack pointer when pit_interrupt_handler was entered. +// registers have been pushed with pusha to this old stack. +// +// stack pointer was moved to the 16kb stack we have from multiboot.s +// +// we need to return a NEW stack pointer where popa will get the registers the new task requires +// +static int first=1; volatile uint32_t my_scheduler(uint32_t oldesp) { - task_list[current_task].esp=oldesp; + + // allows skipping scheduling from gdb + volatile int skippy=0; + if(skippy)return oldesp; + + if(!first) + { + task_list[current_task].esp=oldesp; + } + first=0; for(int i=0;i