kernel/scheduler.c (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#include "cedos/scheduler.h"
#include "cedos/process.h"
#include "cedos/mm/paging.h"
#include "cedos/drivers/console.h"
#include "cedos/core.h"
PROCESS* get_slot(void) {
static PROCESS free_slots[4];
static uint32_t index = 0;
return &(free_slots[index++]);
}
/*!
* Executes a task.
*/
PROCESS_ID sched_exec(PHYS_ADDR page_dir, VIRT_ADDR eip, VIRT_ADDR esp) {
PROCESS* p = get_slot();
p->page_dir = page_dir;
p->eip = eip;
p->esp = esp;
// TODO: add file descriptors for stdin, stdout and stderr
p->state = PSTATE_READY;
return add_process(p);
}
int sched_init(void) {
// TODO: create and start idle process
//sched_exec(create_empty_page_dir(), (void*)0, (void*)0);
return 1;
}
int sched_dispatcher(void) {
}
INTERRUPT(sched_interrupt, frame) {
}