-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschedule.h
127 lines (112 loc) · 4.15 KB
/
schedule.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
* Project 2
* A shortest job remaining scheduler.
*
* Team 3
* Authors:
* Alex Weeks
* Josh Jordahl
* Kevin McIntosh
* Tyler McClung
*/
#ifndef SCHEDULE_H
#define SCHEDULE_H
#include "macros.h"
#include "list.h"
//Comment for print statement to help with Debugging
//#define DEBUG
/*
* Handled by the processor. We should not have to impliment it,
* but will be useful in debugging.
*
* You can find info on it in private_struct.h
*/
struct thread_info;
/* ------------- This is modified by the programmer ------------ */
/* sched_array is the primary data structure used by the scheduler.
* We have left it to be modified by you so that you may
* implement any type of scheduler that you want.
*/
struct sched_array;
/* ---------------- Do NOT Touch -------------- */
/* Sleep Types */
enum sleep_type
{
SLEEP_NORMAL,
SLEEP_NONINTERACTIVE,
SLEEP_INTERACTIVE,
SLEEP_INTERRUPTED
};
/* task_struct */
struct task_struct
{
struct thread_info *thread_info; /* Information about the thread */
int prio, static_prio, normal_prio; /* Priority values */
unsigned long sleep_avg; /* The average time the task
has been sleeping */
//Don't care
unsigned long long last_ran; /* Timestamp for when the
task was last run. */
unsigned long long timestamp; /* A timestamp value */
unsigned long long sched_time; /* The amount of time task
was waiting to be scheduled */
unsigned int time_slice, first_time_slice; /* Timeslice values */
struct list_head run_list; /* Linked list for sched_array */
struct sched_array *array; /* The sched_array the task is in */
enum sleep_type sleep_type; /* What type of sleep task is in */
int need_reschedule; /* Flag, set if task needs to
have schedule called
useful in context_switch()*/
};
/* ------------- This is modified by the programmer ------------ */
/* sched_array is the primary data structure used by the scheduler.
* We have left it to be modified by you so that you may
* implement any type of scheduler that you want.
*/
struct sched_array {
struct list_head list;
struct task_struct *task;
};
/* runqueue */
struct runqueue {
unsigned long nr_running; /* number of runnable tasks */
unsigned long nr_switches; /* number of contextswitches */
unsigned long expired_timestamp; /* time of last array swap */
unsigned long long most_recent_timestamp; /* The last time schedule was run */
struct task_struct *curr; /* the currently running task */
struct sched_array *active; /* pointer to the active priority
array */
//Don't care about this
struct sched_array *expired; /* pointer to the expired
priority array */
//Don't care about this
struct sched_array arrays[2]; /* the actual priority arrays */
//Don't care about this
int best_expired_prio; /* The highest priority that has
* expired thus far */
};
/*----------------------- System Calls ------------------------------*/
/* These calls are provided by the VM for your
* convenience, and mimic system calls provided
* normally by Linux
*/
void context_switch(struct task_struct *next);
unsigned long long sched_clock();
/*------------------YOU MAY EDIT BELOW THIS LINE---------------------*/
/*------------------- User Defined Functions -------------------------*/
/*-------------These functions MUST be defined for the VM-------------*/
void initschedule(struct runqueue *newrq, struct task_struct *seedTask);
void killschedule();
void schedule();
void activate_task(struct task_struct *p);
void deactivate_task(struct task_struct *p);
void __activate_task(struct task_struct *p);
void scheduler_tick(struct task_struct *p);
void sched_fork(struct task_struct *p);
void wake_up_new_task(struct task_struct *p);
long long unsigned get_timestamp();
/*------------These functions are not necessary, but used----------------*
*------------by linux normally for scheduling ----------------*/
void enqueue_task(struct task_struct *p, struct sched_array *array);
void dequeue_task(struct task_struct *p, struct sched_array *array);
#endif