MentOS  0.8.0
The Mentoring Operating System
scheduler.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include "sys/list_head.h"
9 #include "process/process.h"
10 #include "stddef.h"
11 
13 typedef struct runqueue_t {
15  size_t num_active;
17  size_t num_periodic;
19  list_head queue;
23 
25 typedef struct sched_param_t {
37 
39 void scheduler_initialize(void);
40 
44 
48 
52 
56 
61 
64 void scheduler_enqueue_task(task_struct *process);
65 
68 void scheduler_dequeue_task(task_struct *process);
69 
72 void scheduler_run(pt_regs *f);
73 
78 
83 
87 void scheduler_enter_user_jmp(uintptr_t location, uintptr_t stack);
88 
93 
98 int sys_sched_setparam(pid_t pid, const sched_param_t *param);
99 
104 int sys_sched_getparam(pid_t pid, sched_param_t *param);
105 
108 int sys_waitperiod(void);
109 
114 int is_orphaned_pgrp(pid_t gid);
115 
118 void do_exit(int status);
signed int pid_t
The type of process id.
Definition: types.h:9
Process data structures and functions.
runqueue_t runqueue
The list of processes.
Definition: scheduler.c:31
task_struct * scheduler_pick_next_task(runqueue_t *runqueue)
Picks the next task (in scheduler_algorithm.c).
Definition: scheduler_algorithm.c:366
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.
Definition: scheduler.c:268
task_struct * scheduler_get_current_process(void)
Returns the pointer to the current active process.
Definition: scheduler.c:52
uint32_t scheduler_getpid(void)
Returns a non-decreasing unique process id.
Definition: scheduler.c:43
size_t scheduler_get_active_processes(void)
Returns the number of active processes.
Definition: scheduler.c:82
task_struct * scheduler_get_running_process(pid_t pid)
Returns a pointer to the process with the given pid.
Definition: scheduler.c:87
void scheduler_restore_context(task_struct *process, pt_regs *f)
Values from task_struct process to pt_regs.
Definition: scheduler.c:193
int sys_waitperiod(void)
Puts the process on wait until its next period starts.
Definition: scheduler.c:775
void scheduler_enqueue_task(task_struct *process)
Activate the given process.
Definition: scheduler.c:100
void scheduler_store_context(pt_regs *f, task_struct *process)
Values from pt_regs to task_struct process.
Definition: scheduler.c:187
struct sched_param_t sched_param_t
Structure that describes scheduling parameters.
time_t scheduler_get_maximum_vruntime(void)
Returns the maximum vruntime of all the processes in running state.
Definition: scheduler.c:57
void do_exit(int status)
Exit the current process with status.
Definition: scheduler.c:598
void scheduler_dequeue_task(task_struct *process)
Removes the given process from the queue.
Definition: scheduler.c:117
void scheduler_enter_user_jmp(uintptr_t location, uintptr_t stack)
Switch CPU to user mode and start running that given process.
Definition: scheduler.c:204
struct runqueue_t runqueue_t
Structure that contains information about live processes.
int sys_sched_setparam(pid_t pid, const sched_param_t *param)
Set new scheduling settings for the given process.
Definition: scheduler.c:659
void scheduler_run(pt_regs *f)
The RR implementation of the scheduler.
Definition: scheduler.c:133
int sys_sched_getparam(pid_t pid, sched_param_t *param)
Gets the scheduling settings for the given process.
Definition: scheduler.c:687
void scheduler_initialize(void)
Initialize the scheduler.
Definition: scheduler.c:33
bool_t
Define boolean value.
Definition: stdbool.h:9
Define basic data types.
unsigned uintptr_t
Define the unsigned 32-bit pointer.
Definition: stdint.h:36
unsigned int uint32_t
Define the unsigned 32-bit integer.
Definition: stdint.h:18
Interrupt stack frame.
Definition: kernel.h:24
Structure that contains information about live processes.
Definition: scheduler.h:13
size_t num_active
Number of queued processes.
Definition: scheduler.h:15
list_head queue
Queue of processes.
Definition: scheduler.h:19
task_struct * curr
The current running process.
Definition: scheduler.h:21
size_t num_periodic
Number of queued periodic processes.
Definition: scheduler.h:17
Structure that describes scheduling parameters.
Definition: scheduler.h:25
time_t period
Expected period of the task.
Definition: scheduler.h:29
time_t arrivaltime
Absolute time of arrival of the task.
Definition: scheduler.h:33
int sched_priority
Static execution priority.
Definition: scheduler.h:27
bool_t is_periodic
Is task periodic?
Definition: scheduler.h:35
time_t deadline
Absolute deadline.
Definition: scheduler.h:31
this is our task object. Every process in the system has this, and it holds a lot of information....
Definition: process.h:82
unsigned int time_t
Used to store time values.
Definition: time.h:22