9. Scheduling. Proprotional share Flashcards

1
Q

What is concept that proportional share is based on?

A

Instead of optimizing for turnaround or respones time, it aims at making sure each process gets certain CPU percentage of time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is an example of proprotional share scheduling?

A

Lottery scheduling

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What resource is used in lottery scheduling?

A

Tickets

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Is lottery scheduling probablistic or deterministic?

A

Probablistic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does lottery scheduling makes a decision?

A

Randomly choose a number and pick a process into which range this number falls. The bigger the process range (number of tickets), the bigger the chance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the benefit of using randomness?

A

Absence of edge cases and no or almost no state management

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What mechanism are available in ticket system?

A

1) Ticket currency. Regardless of the amount of tickets user holds, the system can transform this amount into the global currency
2) Ticket transfer. A process can temporarily held off its tickets to another process
3) Ticket inflation. A process can temporarily raise or lower number of tickets it owns. Makes sense only in a trusted environment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

In ticket lottery, is it true that scheduling decision depends exactly on the number of tickets the process holds?

A

Not exactly. While traversing a list of processes with their tickets, each process tickets are added to a counter until the counter exceeds the random number.

To optimize this mechanism, list of processes and their tickets can be sorted

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What metric can be used to determine how good fair scheduler is? How does this metric behave in relation to job’s length?

A

Fairness metric. It’s a value obtained by dividing the time of first job finish by the time of second job. The closer this value to 1, the more fair the scheduler

With short jobs, this metric won’t do good, but the longer the jobs run, the more fair will be scheduler.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What kind of deterministic fair scheduler exists? How does it work?

A

Stride scheduler. Each job has a stride, which is inverse proportion to the number of tickets it has (for example, job A has 20 tickets, 10000/20, job’s stride is 500). Every time a process runs, a counter for it is incremented by its stride (called pass value). The process with lowest pass value is scheduled

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is open question we have with stride scheduling?

A

What pass value should be for a new process? If set to 0, it will monopolize the CPU

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is current Linux scheduler?

A

The Linux Completely Fair Scheduler (CFS)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How does CFS work?

A

As each process runs, it accumulates “vruntime”. In the most basic case, “vruntime” increases at the same rate, in proportion with real time. When a scheduling decision occurs, CFS will pick the process with lowest “vruntime”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How does CFS know when to perform a context switch to let other process run?

A

Through various control parameters:
- sched_latency: determines how long should process run before considering a switch. This value is divided by number of processes to determine a time slice for a process. Its default value is 48 milliseconds

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How is problem of too many context switches solved when there are too many processes running and time slice obtained with sched_latency is too small?

A

Another parameter:
- min_granularity: a minimal value for a time slice. The process can’t run shorter than this value. Usually set to 6 milliseconds

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Since CFS is a fair scheduler, how does it utilize niceness to give some process more time to run?

A

OS utilizes prio_to_weight structure that maps priority of process to the weight. The time slice for a process is obtained by diving the weight of process by sum of weights of all processes and multiplying by sched_latency

The “vrtuntime” also has to be adjusted for process. The value added to current value of runtime is default weight (1024) divided by weight of the process. This way, the processes with lower nice value accumulate “vruntime” slower.

17
Q

How does CFS achieves the goal of efficiency when it needs to find next job to run?

A

By keeping processes in “red-black tree” which is more efficient than usual binary trees and achieves logarithmic time by smartly managing depth of a tree. It’s a type of balanced tree. Only running or runnable processes are kept in this structure. Processes are ordered by “vruntime” in this tree.

18
Q

How does CFS handle I/O?

A

When jobs sleeps, it does not accumulate “vruntime” which might then make process monopolize CPU if not handled. Instead, when such process is waken up, it’s “vruntime” is set to a minimal number in the tree.