Scheduler. More...
Functions | |
cpu_state_t * | schedule (cpu_state_t *cpu) |
Returns the next task to run. More... | |
cpu_state_t * | schedule_switch_task (task_pid_t next_task) |
Switches to a given task. More... | |
task_pid_t | schedule_get_current_task () |
Returns the current task's PID. More... | |
task_pid_t | schedule_get_next_task () |
Returns the next running task's PID. More... | |
void | schedule_finalize_tasks () |
Destroys tasks marked for removal. | |
Variables | |
static task_pid_t | current_task = 0 |
the currently running task pid | |
static uint32_t | ticks_per_time_slice = 1 |
1 tick = frequency of the PIT | |
Scheduler.
The scheduler switches tasks using a simple round robin strategy.
cpu_state_t * schedule | ( | cpu_state_t * | cpu | ) |
Returns the next task to run.
cpu | the current task's CPU state |
Does nothing if there are no tasks yet.
Does not switch tasks if the current task's time slice is not over yet.
Otherwise switches to the next task.
Definition at line 26 of file schedule.c.
task_pid_t schedule_get_current_task | ( | ) |
Returns the current task's PID.
Definition at line 74 of file schedule.c.
task_pid_t schedule_get_next_task | ( | ) |
Returns the next running task's PID.
Definition at line 82 of file schedule.c.
cpu_state_t * schedule_switch_task | ( | task_pid_t | next_task | ) |
Switches to a given task.
next_task | the new task's PID |
If we want to switch to userspace, tells the TSS which kernel stack to load when an interrupt occurs.
Refills the new task's time slice.
Switches to the new virtual address space.
Definition at line 47 of file schedule.c.