From 6a886cb2a4af303fae01b61a2e6590ca22bb4a3e Mon Sep 17 00:00:00 2001 From: Miguel Date: Thu, 13 Sep 2018 02:14:46 +0200 Subject: reentrenacy for newilb --- kernel/scheduler.c | 46 ++++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 28 deletions(-) (limited to 'kernel/scheduler.c') diff --git a/kernel/scheduler.c b/kernel/scheduler.c index 6c7df28..985b3bf 100644 --- a/kernel/scheduler.c +++ b/kernel/scheduler.c @@ -102,10 +102,9 @@ volatile uint32_t scheduler_run(uint32_t oldesp,uint32_t force_pid) if(task_list[cpu][idx].active && !task_list[cpu][idx].wait) // find active non-blocked task { - //TODO: do NOT do this! - //klog("schedule %d->%d in cpu %d",current_task[cpu],idx,cpu ); + //TODO: do NOT do this! deadlock imminent! + //if(cpu==0)klog("schedule %d->%d on cpu %d",current_task[cpu],idx,cpu ); current_task[cpu]=idx; - install_tss(cpu,task_list[cpu][idx].esp0); x86_set_page_directory(task_list[cpu][idx].vmem); return task_list[cpu][idx].esp; @@ -138,12 +137,9 @@ void scheduler_func() uint32_t alloc; uint32_t entry_global=load_elf(BIN_INIT,&alloc); task_set_brk(alloc); - klog("breakpoint: 0x%08x",alloc); asm_usermode(entry_global); - while(1); + while(1); } -// else syscall_write(1, "x",1); // stdout - } } @@ -174,7 +170,7 @@ volatile int add_task(uint32_t parent,uint32_t vmem) uint32_t *source=(uint32_t *)task_list[cpu][parent].esp; uint32_t *dst=(uint32_t *)task_list[cpu][i].esp; - for(int x=0;x<100;x++) //TODO: better copy this page too instead of stack + for(int x=0;x<100;x++) //TODO: maybe better copy this page too instead of stack { *dst=*source; dst++; @@ -189,7 +185,6 @@ volatile int add_task(uint32_t parent,uint32_t vmem) return i; } } - kpanic("out of task slots!"); } @@ -206,8 +201,6 @@ void task_syscall_worker() uint32_t cpu=smp_get(SMP_APIC_ID); while(1) { - //klog("checking if any pending syscalls."); - bool nowork=true; for(int i=0;i [%d] (free blocks remaining: %d )", pid, ret,0); return ret; } volatile uint32_t task_clone(uint32_t pid) { - uint32_t cpu=smp_get(SMP_APIC_ID); -//TODO: what will happen if we get rescheduled!?!?! + uint32_t cpu=smp_get(SMP_APIC_ID); int ret=add_task(pid,vmem_new_space_dir(task_list[cpu][pid].vmem,true)); klog("[%d] cloned -> [%d] (free blocks remaining: %d )", pid, ret,0); return ret; -- cgit v1.2.3