diff options
Diffstat (limited to 'kernel/scheduler.c')
| -rw-r--r-- | kernel/scheduler.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/kernel/scheduler.c b/kernel/scheduler.c index 3136868..453d4f4 100644 --- a/kernel/scheduler.c +++ b/kernel/scheduler.c @@ -24,12 +24,12 @@ static volatile struct task_list_struct volatile bool waiting; volatile bool skipwait; volatile uint32_t brk; + volatile uint32_t esp0; }volatile task_list[MAX_TASKS]; volatile int add_task(uint32_t esp, uint32_t vmem) { - for(int i=0;i<MAX_TASKS;i++) { if(task_list[i].active!=true) @@ -37,6 +37,7 @@ 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].esp0 = kballoc(4)+4*4096; task_list[i].active=true; task_list[i].waiting=false; task_list[i].skipwait=false; @@ -62,10 +63,6 @@ static int first=1; volatile uint32_t my_scheduler(uint32_t oldesp) { - // allows skipping scheduling from gdb - volatile int skippy=0; - if(skippy)return oldesp; - if(!first) { task_list[current_task].esp=oldesp; @@ -82,6 +79,7 @@ volatile uint32_t my_scheduler(uint32_t oldesp) // log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"switch from %d to %d", current_task, pid); current_task=pid; + install_tss(task_list[pid].esp0); x86_set_page_directory(task_list[pid].vmem); return task_list[pid].esp; @@ -158,21 +156,20 @@ volatile void scheduler_init(pdirectory *dir) { current_task=0; - // this is our main task on slot 0 + // this is our main user task on slot 0 task_list[0].parent=0; task_list[0].active=true; task_list[0].waiting=false; task_list[0].vmem=dir; - task_list[0].esp = kballoc(4); // 0; // will be set by next task_switch_next() call. + task_list[0].esp = kballoc(4)+4*4096; + task_list[0].esp0 = kballoc(4)+4*4096; task_list[1].parent=0; task_list[1].active=true; task_list[1].waiting=false; task_list[1].vmem=dir; - task_list[1].esp = kballoc(4); // fresh 16kb stack from here. - - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"fresh esp on: 0x%08X",task_list[1].esp+4*4096-1); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"fresh esp on: 0x%08X",task_list[0].esp+4*4096-1); + task_list[1].esp = kballoc(4)+4*4096; + task_list[1].esp0 = 0; // not needed by kernel space task task_pusha(task_list[1].esp); // pusha but to alternative location task_pusha(task_list[0].esp); // pusha but to alternative location |
