MentOS  0.8.0
The Mentoring Operating System
Classes | Typedefs | Functions
scheduler.h File Reference

Scheduler structures and functions. More...

Go to the source code of this file.

Classes

struct  runqueue_t
 Structure that contains information about live processes. More...
 
struct  sched_param_t
 Structure that describes scheduling parameters. More...
 

Typedefs

typedef struct runqueue_t runqueue_t
 Structure that contains information about live processes.
 
typedef struct sched_param_t sched_param_t
 Structure that describes scheduling parameters.
 

Functions

void scheduler_initialize (void)
 Initialize the scheduler.
 
uint32_t scheduler_getpid (void)
 Returns a non-decreasing unique process id. More...
 
task_structscheduler_get_current_process (void)
 Returns the pointer to the current active process. More...
 
time_t scheduler_get_maximum_vruntime (void)
 Returns the maximum vruntime of all the processes in running state. More...
 
size_t scheduler_get_active_processes (void)
 Returns the number of active processes. More...
 
task_structscheduler_get_running_process (pid_t pid)
 Returns a pointer to the process with the given pid. More...
 
void scheduler_enqueue_task (task_struct *process)
 Activate the given process. More...
 
void scheduler_dequeue_task (task_struct *process)
 Removes the given process from the queue. More...
 
void scheduler_run (pt_regs *f)
 The RR implementation of the scheduler. More...
 
void scheduler_store_context (pt_regs *f, task_struct *process)
 Values from pt_regs to task_struct process. More...
 
void scheduler_restore_context (task_struct *process, pt_regs *f)
 Values from task_struct process to pt_regs. More...
 
void scheduler_enter_user_jmp (uintptr_t location, uintptr_t stack)
 Switch CPU to user mode and start running that given process. More...
 
task_structscheduler_pick_next_task (runqueue_t *runqueue)
 Picks the next task (in scheduler_algorithm.c). More...
 
int sys_sched_setparam (pid_t pid, const sched_param_t *param)
 Set new scheduling settings for the given process. More...
 
int sys_sched_getparam (pid_t pid, sched_param_t *param)
 Gets the scheduling settings for the given process. More...
 
int sys_waitperiod (void)
 Puts the process on wait until its next period starts. More...
 
int is_orphaned_pgrp (pid_t gid)
 Returns 1 if the given group is orphaned, the session leader of the group is no longer alive. More...
 
void do_exit (int status)
 Exit the current process with status. More...
 

Detailed Description

Scheduler structures and functions.

Function Documentation

◆ do_exit()

void do_exit ( int  status)

Exit the current process with status.

Parameters
statusThe exit status of the current process

◆ is_orphaned_pgrp()

int is_orphaned_pgrp ( pid_t  gid)

Returns 1 if the given group is orphaned, the session leader of the group is no longer alive.

Parameters
gidID of the group
Returns
1 if the group is orphan, 0 otherwise.

◆ scheduler_dequeue_task()

void scheduler_dequeue_task ( task_struct process)

Removes the given process from the queue.

Parameters
processProcess that has to be activated.

◆ scheduler_enqueue_task()

void scheduler_enqueue_task ( task_struct process)

Activate the given process.

Parameters
processProcess that has to be activated.

◆ scheduler_enter_user_jmp()

void scheduler_enter_user_jmp ( uintptr_t  location,
uintptr_t  stack 
)

Switch CPU to user mode and start running that given process.

Parameters
locationThe instruction pointer of the process we are starting.
stackAddress of the stack of that process.

◆ scheduler_get_active_processes()

size_t scheduler_get_active_processes ( void  )

Returns the number of active processes.

Returns
Number of processes.

◆ scheduler_get_current_process()

task_struct* scheduler_get_current_process ( void  )

Returns the pointer to the current active process.

Returns
Pointer to the current process.

◆ scheduler_get_maximum_vruntime()

time_t scheduler_get_maximum_vruntime ( void  )

Returns the maximum vruntime of all the processes in running state.

Returns
A maximum vruntime value.

◆ scheduler_get_running_process()

task_struct* scheduler_get_running_process ( pid_t  pid)

Returns a pointer to the process with the given pid.

Parameters
pidThe pid of the process we are looking for.
Returns
Pointer to the process, or NULL if we cannot find it.

◆ scheduler_getpid()

uint32_t scheduler_getpid ( void  )

Returns a non-decreasing unique process id.

Returns
Process identifier (PID).

The current unused PID.

◆ scheduler_pick_next_task()

task_struct* scheduler_pick_next_task ( runqueue_t runqueue)

Picks the next task (in scheduler_algorithm.c).

Parameters
runqueuePointer to the runqueue.
Returns
The next task to execute.

◆ scheduler_restore_context()

void scheduler_restore_context ( task_struct process,
pt_regs f 
)

Values from task_struct process to pt_regs.

Parameters
processThe process for which we are restoring the registers in CPU .
fThe set of registers we are restoring.

◆ scheduler_run()

void scheduler_run ( pt_regs f)

The RR implementation of the scheduler.

Parameters
fThe context of the process.

◆ scheduler_store_context()

void scheduler_store_context ( pt_regs f,
task_struct process 
)

Values from pt_regs to task_struct process.

Parameters
fThe set of registers we are saving.
processThe process for which we are saving the CPU registers status.

◆ sys_sched_getparam()

int sys_sched_getparam ( pid_t  pid,
sched_param_t param 
)

Gets the scheduling settings for the given process.

Parameters
pidID of the process we are manipulating.
paramWhere we store the parameters.
Returns
1 on success, -1 on error.

◆ sys_sched_setparam()

int sys_sched_setparam ( pid_t  pid,
const sched_param_t param 
)

Set new scheduling settings for the given process.

Parameters
pidID of the process we are manipulating.
paramNew parameters.
Returns
1 on success, -1 on error.

◆ sys_waitperiod()

int sys_waitperiod ( void  )

Puts the process on wait until its next period starts.

Returns
0 on success, a negative value on failure.