#include "scheduler.h" #include "kernel.h" #include "gdt.h" #include "log.h" #include "smp.h" #include "mem.h" #include "fs/elf.h" #include "asm_x86.h" #include "asm_task.h" #include "asm_usermode.h" #include "kmalloc.h" #include "vmem.h" #include "syscalls.h" #include "fs/fs.h" #include "fs/ext2.h" #define NO_TASK 0xffffffff // we hold this stuff per cpu static volatile uint32_t current_task[SMP_MAX_PROC]; // we hold this stuff per cpu static volatile struct task_list_struct { volatile bool active; // is this slot used (Y/N) volatile uint32_t pid; // process id (TODO) volatile uint32_t parent; // parent process id volatile uint32_t esp; // stack pointer of the task volatile uint32_t esp0; // tss.esp0 volatile struct pdirectory *vmem; // number of virtual memory table volatile uint32_t brk; // memory brk pos volatile bool wait; // waiting for syscall to be processed. volatile uint32_t eax; volatile uint32_t ebx; volatile uint32_t ecx; volatile uint32_t edx; }task_list[SMP_MAX_PROC][MAX_TASKS]; // init tasks // volatile void scheduler_init(uint32_t cpu, void *dir) { 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!?!?! 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; } volatile int task_get_current_pid() { uint32_t cpu=smp_get(SMP_APIC_ID); return current_task[cpu]; } volatile uint32_t task_get_brk() { uint32_t cpu=smp_get(SMP_APIC_ID); return task_list[cpu][current_task[cpu]].brk; } volatile void task_set_brk(uint32_t brk) { uint32_t cpu=smp_get(SMP_APIC_ID); task_list[cpu][current_task[cpu]].brk=brk; }