From 4ddca59e2c07a98988ffb07571d2b35c4c90f5ac Mon Sep 17 00:00:00 2001 From: Miguel Date: Fri, 28 Sep 2018 01:52:07 +0200 Subject: reactiveate threads. allow user space access to framebuffer --- kernel/scheduler.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'kernel/scheduler.c') diff --git a/kernel/scheduler.c b/kernel/scheduler.c index 20b69ed..0c24f94 100644 --- a/kernel/scheduler.c +++ b/kernel/scheduler.c @@ -35,6 +35,7 @@ static uint32_t nextPID() // we hold this stuff per cpu static volatile uint32_t current_task[SMP_MAX_PROC]; +static volatile uint32_t last_task[SMP_MAX_PROC]; // last non ring1 task // we hold this stuff per cpu static volatile struct task_list_struct @@ -69,6 +70,7 @@ volatile void scheduler_init(uint32_t cpu, void *dir) } current_task[cpu]=0; + last_task[cpu]=0; // need to make space on the esp stacks for pushing vals vias task_pusha @@ -117,6 +119,8 @@ static uint32_t scheduler_schedule(uint32_t idx) uint32_t cpu=smp_get(SMP_APIC_ID); if(task_list[cpu][idx].active && !task_list[cpu][idx].syscall) { + if(current_task[cpu]!=0)last_task[cpu]=current_task[cpu]; + current_task[cpu]=idx; install_tss(cpu,task_list[cpu][idx].esp0); x86_set_page_directory(task_list[cpu][idx].vmem); @@ -150,19 +154,21 @@ volatile uint32_t scheduler_run(uint32_t oldesp,uint32_t preference) uint32_t esp; esp=scheduler_schedule(preference); // try preference + if(esp)return esp; for(int i=0;i