MentOS
0.8.0
The Mentoring Operating System
|
Scheduler structures and functions. More...
Macros | |
#define | __DEBUG_HEADER__ "[SCHED ]" |
Change header. | |
#define | __DEBUG_LEVEL__ LOGLEVEL_NOTICE |
Set log level. | |
#define | RETURN_PROCESS_ATTR_OR_EPERM(attr) |
Returns the attributes of the runnign process. More... | |
#define | FAIL_ON_INV_ID(id) if (id < 0) { return -EINVAL; } |
Checks the given ID. | |
#define | FAIL_ON_INV_ID_OR_PROC(id) |
Checks the ID, and if there is a running process. More... | |
#define | IF_PRIVILEGED_SET_ALL_AND_RETURN(attr) |
If the process is ROOT, set the attribute and return 0. More... | |
#define | IF_RESET_SET_AND_RETURN(attr) |
Checks the attributes, resets them, and returns 0. More... | |
#define | SET_IF_PRIVILEGED_OR_FAIL(attr) |
If the process is ROOT set the attribute, otherwise return failure. More... | |
Functions | |
void | enter_userspace (uintptr_t location, uintptr_t stack) |
Assembly function setting the kernel stack to jump into location in Ring 3 mode (USER mode). More... | |
void | scheduler_initialize (void) |
Initialize the scheduler. | |
uint32_t | scheduler_getpid (void) |
Returns a non-decreasing unique process id. More... | |
task_struct * | scheduler_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_struct * | scheduler_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... | |
static int | try_to_wake_up (task_struct *process, unsigned mode, int sync) |
Awakens a sleeping process. More... | |
int | default_wake_function (wait_queue_entry_t *wait, unsigned mode, int sync) |
The default wake function, a wrapper for try_to_wake_up. More... | |
wait_queue_entry_t * | sleep_on (wait_queue_head_t *wq) |
Sets the state of the current process to TASK_UNINTERRUPTIBLE and inserts it into the specified wait queue. More... | |
int | is_orphaned_pgrp (pid_t pgid) |
Returns 1 if the given group is orphaned, the session leader of the group is no longer alive. More... | |
pid_t | sys_getpid (void) |
Returns the process ID (PID) of the calling process. More... | |
pid_t | sys_getsid (pid_t pid) |
Return session id of the given process. If pid == 0 return the SID of the calling process If pid != 0 return the SID corresponding to the process having identifier == pid. More... | |
pid_t | sys_setsid (void) |
creates a new session if the calling process is not a process group leader. The calling process is the leader of the new session (i.e., its session ID is made the same as its process ID). The calling process also becomes the process group leader of a new process group in the session (i.e., its process group ID is made the same as its process ID). More... | |
pid_t | sys_getpgid (pid_t pid) |
returns the Process Group ID (PGID) of the process specified by pid. If pid is zero, the process ID of the calling process is used. More... | |
int | sys_setpgid (pid_t pid, pid_t pgid) |
Sets the Process Group ID (PGID) of the process specified by pid. If pid is zero, the process ID of the calling process is used. More... | |
uid_t | sys_getuid (void) |
Returns the real User ID (UID) of the calling process. More... | |
uid_t | sys_geteuid (void) |
Returns the effective User ID (UID) of the calling process. More... | |
gid_t | sys_getgid (void) |
returns the real group ID of the calling process. More... | |
gid_t | sys_getegid (void) |
returns the effective group ID of the calling process. More... | |
int | sys_setuid (uid_t uid) |
Tries to set the User ID (UID) of the calling process. More... | |
int | sys_setgid (gid_t gid) |
sets the group ID of the calling process. More... | |
int | sys_setreuid (uid_t ruid, uid_t euid) |
Set the real and effective User ID (UID) of the calling process. More... | |
int | sys_setregid (gid_t rgid, gid_t egid) |
sets the real and effective group ID of the calling process. More... | |
pid_t | sys_getppid (void) |
Returns the parent process ID (PPID) of the calling process. More... | |
int | sys_nice (int increment) |
Adds the increment to the priority value of the task. More... | |
pid_t | sys_waitpid (pid_t pid, int *status, int options) |
Suspends execution of the calling thread until a child specified by pid argument has changed state. More... | |
void | do_exit (int exit_code) |
Exit the current process with status. More... | |
void | sys_exit (int exit_code) |
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... | |
static int | __response_time_analysis (void) |
Performs the response time analysis for the current list of periodic processes. More... | |
static double | __compute_utilization_factor (void) |
Computes the total utilization factor. More... | |
int | sys_waitperiod (void) |
Puts the process on wait until its next period starts. More... | |
Variables | |
runqueue_t | runqueue |
The list of processes. | |
Scheduler structures and functions.
#define FAIL_ON_INV_ID_OR_PROC | ( | id | ) |
Checks the ID, and if there is a running process.
#define IF_PRIVILEGED_SET_ALL_AND_RETURN | ( | attr | ) |
#define IF_RESET_SET_AND_RETURN | ( | attr | ) |
#define RETURN_PROCESS_ATTR_OR_EPERM | ( | attr | ) |
#define SET_IF_PRIVILEGED_OR_FAIL | ( | attr | ) |
|
inlinestatic |
Computes the total utilization factor.
|
static |
Performs the response time analysis for the current list of periodic processes.
int default_wake_function | ( | wait_queue_entry_t * | wait, |
unsigned | mode, | ||
int | sync | ||
) |
The default wake function, a wrapper for try_to_wake_up.
wait | The pointer to the wait queue. |
mode | The type of wait (TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE). |
sync | Specifies if the wakeup should be synchronous. |
void do_exit | ( | int | status | ) |
Exit the current process with status.
status | The exit status of the current process |
Assembly function setting the kernel stack to jump into location in Ring 3 mode (USER mode).
location | The location where to jump. |
stack | The stack to use. |
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.
gid | ID of the group |
void scheduler_dequeue_task | ( | task_struct * | process | ) |
Removes the given process from the queue.
process | Process that has to be activated. |
void scheduler_enqueue_task | ( | task_struct * | process | ) |
Activate the given process.
process | Process that has to be activated. |
Switch CPU to user mode and start running that given process.
location | The instruction pointer of the process we are starting. |
stack | Address of the stack of that process. |
size_t scheduler_get_active_processes | ( | void | ) |
Returns the number of active processes.
task_struct* scheduler_get_current_process | ( | void | ) |
Returns the pointer to the current active process.
time_t scheduler_get_maximum_vruntime | ( | void | ) |
Returns the maximum vruntime of all the processes in running state.
task_struct* scheduler_get_running_process | ( | pid_t | pid | ) |
Returns a pointer to the process with the given pid.
pid | The pid of the process we are looking for. |
uint32_t scheduler_getpid | ( | void | ) |
Returns a non-decreasing unique process id.
The current unused PID.
void scheduler_restore_context | ( | task_struct * | process, |
pt_regs * | f | ||
) |
Values from task_struct process to pt_regs.
process | The process for which we are restoring the registers in CPU . |
f | The set of registers we are restoring. |
void scheduler_run | ( | pt_regs * | f | ) |
The RR implementation of the scheduler.
f | The context of the process. |
void scheduler_store_context | ( | pt_regs * | f, |
task_struct * | process | ||
) |
Values from pt_regs to task_struct process.
f | The set of registers we are saving. |
process | The process for which we are saving the CPU registers status. |
wait_queue_entry_t* sleep_on | ( | wait_queue_head_t * | wq | ) |
Sets the state of the current process to TASK_UNINTERRUPTIBLE and inserts it into the specified wait queue.
wq | Waitqueue where to sleep. |
void sys_exit | ( | int | exit_code | ) |
The exit() function causes normal process termination.
exit_code | The exit code. |
gid_t sys_getegid | ( | void | ) |
returns the effective group ID of the calling process.
uid_t sys_geteuid | ( | void | ) |
Returns the effective User ID (UID) of the calling process.
gid_t sys_getgid | ( | void | ) |
returns the real group ID of the calling process.
returns the Process Group ID (PGID) of the process specified by pid. If pid is zero, the process ID of the calling process is used.
pid | process of which we want to know the PGID. |
pid_t sys_getpid | ( | void | ) |
Returns the process ID (PID) of the calling process.
pid_t sys_getppid | ( | void | ) |
Returns the parent process ID (PPID) of the calling process.
Return session id of the given process. If pid == 0 return the SID of the calling process If pid != 0 return the SID corresponding to the process having identifier == pid.
pid | process identifier from wich we want the SID |
uid_t sys_getuid | ( | void | ) |
Returns the real User ID (UID) of the calling process.
int sys_nice | ( | int | increment | ) |
Adds the increment to the priority value of the task.
increment | The modifier to apply to the nice value. |
int sys_sched_getparam | ( | pid_t | pid, |
sched_param_t * | param | ||
) |
Gets the scheduling settings for the given process.
pid | ID of the process we are manipulating. |
param | Where we store the parameters. |
int sys_sched_setparam | ( | pid_t | pid, |
const sched_param_t * | param | ||
) |
Set new scheduling settings for the given process.
pid | ID of the process we are manipulating. |
param | New parameters. |
int sys_setgid | ( | gid_t | gid | ) |
sets the group ID of the calling process.
gid | group id |
Sets the Process Group ID (PGID) of the process specified by pid. If pid is zero, the process ID of the calling process is used.
pid | process of which we want to set the PGID. |
pgid | the PGID we want to set. |
sets the real and effective group ID of the calling process.
rgid | real group id |
egid | effective group id |
Set the real and effective User ID (UID) of the calling process.
ruid | the new real User ID. |
euid | the new effective User ID. |
pid_t sys_setsid | ( | void | ) |
creates a new session if the calling process is not a process group leader. The calling process is the leader of the new session (i.e., its session ID is made the same as its process ID). The calling process also becomes the process group leader of a new process group in the session (i.e., its process group ID is made the same as its process ID).
int sys_setuid | ( | uid_t | uid | ) |
Tries to set the User ID (UID) of the calling process.
uid | the new User ID. |
int sys_waitperiod | ( | void | ) |
Puts the process on wait until its next period starts.
Suspends execution of the calling thread until a child specified by pid argument has changed state.
pid | The pid to wait. |
status | If not NULL, store status information here. |
options | Determines the wait behaviour. |
|
inlinestatic |
Awakens a sleeping process.
process | The process that should be awakened |
mode | The type of wait (TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE). |
sync | Specifies if the wakeup should be synchronous. |