Question: What to do for this Project ( Implementation of Fair Scheduler ) : Change ready queue from unsorted list to list sorted by vruntime and

What to do for this Project
(
Implementation of Fair Scheduler
)
:
Change ready queue from unsorted list to list sorted by vruntime and tid
Each tick calculate the ideal runtime and compare time running
If time running is longer yield and add to ready queue
(
unless ready to terminate
)
Thread block
Remove from ready queue
Thread Unblock
Add to ready queue
Cause current thread to yield if CPU was idle or if get sleeping boost
What to do
-
variables
Variables to think about :
Vruntime
-
for each thread
Weight table
-
for scheduler to use
Min
_
vruntime
-
for each ready queue
vruntime
_
0
-
for each thread
CPU time consumed
-
for each thread
Thread
s time slice
(
ideal runtime
)
for each thread
Number of threads running or ready for each ready queue
Weight of thread
-
for each thread
Sum of weights
-
for each ready queue
What to do
-
Initialization
Some variables need to be initialized when each CPU first thread is initialized and ready queue is set
-
up
Some variables need to be initialized when threads are created
Each Tick
Thread
_
tick calls sched
_
tick
Determine if thread needs to yield
Calculate and compare ideal runtime to the amount of time that thread has been running
Then thread
_
yield calls sched
_
yield
Update how long thread has been running
Add to ready
_
queue in order by runtime and tid
Update number of threads in ready queue
Update sum of weights
Then thread
_
tick calls schedule
(
)
Calls next thread to run which calls sched
_
pick
_
next
Remove from ready queue just like before but also
Update any variables about when it was last run or runtime was calculated etc if you are using them
Update number of threads in ready queue
Update sum of weights
Calls switch thread
Calls thread
_
schedule
_
tail
Thread Block
/
Unblock
Block
Remove from ready queue
Update variables
Unblock
Add to ready queue
Update variables
Trigger schedule if CPU was NULL or if thread got a sleeping boost
Theory :
CFS
-
Niceness :
Niceness
(
in thread struct
)
indication of priority
Higher niceness
=
lower priority
Function: int thread
_
get
_
nice
(
void
)
Returns the current thread's nice value.
Function: void thread
_
set
_
nice
(
int new
_
nice
)
Sets the current thread's nice value to new
_
nice.
CFS Weights :
static const uint
3
2
_
t prio
_
to
_
weight
[
4
0
]
=
{
/
*
-
2
0
*
/
8
8
7
6
1
,
7
1
7
5
5
,
5
6
4
8
3
,
4
6
2
7
3
,
3
6
2
9
1
,
/
*
-
1
5
*
/
2
9
1
5
4
,
2
3
2
5
4
,
1
8
7
0
5
,
1
4
9
4
9
,
1
1
9
1
6
,
/
*
-
1
0
*
/
9
5
4
8
,
7
6
2
0
,
6
1
0
0
,
4
9
0
4
,
3
9
0
6
,
/
*
-
5
*
/
3
1
2
1
,
2
5
0
1
,
1
9
9
1
,
1
5
8
6
,
1
2
7
7
,
/
*
0
*
/
1
0
2
4
,
8
2
0
,
6
5
5
,
5
2
6
,
4
2
3
,
/
*
5
*
/
3
3
5
,
2
7
2
,
2
1
5
,
1
7
2
,
1
3
7
,
/
*
1
0
*
/
1
1
0
,
8
7
,
7
0
,
5
6
,
4
5
,
/
*
1
5
*
/
3
6
,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!