UnnamedOS
Schedule

Scheduler. More...

+ Collaboration diagram for Schedule:

Functions

cpu_state_tschedule (cpu_state_t *cpu)
 Returns the next task to run. More...
 
cpu_state_tschedule_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
 

Detailed Description

Scheduler.

The scheduler switches tasks using a simple round robin strategy.

See also
http://wiki.osdev.org/Scheduling_Algorithms

Function Documentation

cpu_state_t * schedule ( cpu_state_t cpu)

Returns the next task to run.

Parameters
cputhe current task's CPU state
Returns
the next 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.

+ Here is the call graph for this function:

task_pid_t schedule_get_current_task ( )

Returns the current task's PID.

Returns
the current task's PID

Definition at line 74 of file schedule.c.

+ Here is the caller graph for this function:

task_pid_t schedule_get_next_task ( )

Returns the next running task's PID.

Returns
the next running task's PID

Definition at line 82 of file schedule.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

cpu_state_t * schedule_switch_task ( task_pid_t  next_task)

Switches to a given task.

Parameters
next_taskthe new task's PID
Returns
the new task's CPU state

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.

+ Here is the call graph for this function:

+ Here is the caller graph for this function: