P3L1 - Scheduling Flashcards

1
Q

What is the role of the CPU Scheduler?

A

To decide how and when the processes (and their threads) access the shared CPUs

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

T/F: Scheduler concerns itself with both user level tasks and kernel level tasks

A

True!

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

When do you need to run the scheduler?

A

Whenever the CPU becomes idle

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

What is a common amount of time given to a task?

A

Timeslice

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

What are the steps that occur when the scheduler selects a task to be scheduled?

A
  1. Switch to new task
  2. Enter user mode
  3. Set program counter
  4. Execution begins!
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the structure of the ready queue known as?

A

runqueue

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

_____ scheduling assumes that once a task is assigned to a CPU, it will run on that CPU until its finished

A

Run to Completion

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

What are some common metrics for comparing schedulers?

A
  1. Throughput
  2. Average job completion time
  3. Average job wait time
  4. CPU utilization
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

_____ algorithm has tasks scheduled in the order in which they arrive?

A

First come First serve (FCFS)

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

What is an alternative to using execution time when choosing tasks to schedule?

A

Priority levels

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

When scheduling based on priority levels, which task should run first?

A

The task with the highest priority level

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

What is an effective way to be able to quickly tell a task’s priority

A

Maintain a separate runqueue for each priority level

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

What is one dangerous situation that can occur with priority scheduling?

A

Starvation

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

What is starvation in the context of scheduling?

A

When low priority tasks are essentially never scheduled because higher priority tasks continually enter the system and take precedence

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

What is one mechanism to protect against starvation?

A

Priority aging - The priority of a task is not just the numerical property but a function of the actual priority and the amount of time the task has spent in the runqueue

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

What is priority inversion?

A

When the highest priority task that SHOULD run cannot run because the lowest priority task is holding a mutex it needs

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

What is one way to combat priority inversion?

A

Temporarily boost the priority of the mutex owner long enough to allow it to complete

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

Define a timeslice?

A

The maximum amount of uninterrupted time that can be given to a task

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

T/F: A task may run for a smaller amount of time than what the timeslice specifies?

20
Q

What is one use of timeslices?

A

To allow tasks to be interleaved

21
Q

What are the downsides of timeslicing?

A

The overhead - We have to interrupt the running task, execute the scheduler ,and have to context switch to the new task

22
Q

How long should a timeslice be?

A

CPU intensive tasks –> Prefer longer timeslice values

I/O intensive tasks –> Prefer shorter timeslice values

23
Q

T/F: A runqueue data structure is only LOGICALLY a queue?

A

True! It can be implemented as multiple queues or even a tree

24
Q

____ is a structure that maintains multiple distinct queues, each differentiated by their timeslice values

A

Multi queue

25
T/F: The topmost level of a multi queue has the larger timeslice value!
False! It holds the lowest
26
How did the Linux O(1) Scheduler get its name?
It can add/select tasks in constant time regardless of the number of tasks in the system
27
How many priority levels does the Linux O(1) scheduler have?
140 priority levels
28
What are levels 0-99 used for in the Linux O(1) scheduler?
real time tasks
29
What are levels 100-139 used for in the Linux O(1) scheduler?
timesharing tasks
30
What is the feedback for the Linux O(1) scheduler?
How long a task spent sleeping during its timeslice
31
How is the runqueue implemented for the Linux O(1) scheduler?
As two arrays - active and expired
32
Which of the two arrays of the Linux O( 1) schedulers runqueue is used for selecting the next task to run?
Active
33
What are some downsides of the Linux O(1) scheduler?
1. A task cannot run again until everything in the active array is complete 2. It makes no fairness guarantees
34
What scheduler replaced the Linux O(1) scheduler?
The CFS (Completely Fair Scheduler)
35
What type of data structure is used for the runquee for the CFS?
A red-black (self balancing) tree
36
How are tasks ordered in the runqueue for CFS?
Based on amount of time that they spent running on the CPU - vruntime
37
How long does selection take for CFS?
Constant time
38
How long does addition take for CFS?
Log(# of tasks)
39
Describe a shared memory multiprocessor
Multiple CPUs each with their own private L1/L2 cache, as well as a LLC which may or may not be shared. Lastly there is a DRAM shared across CPU's
40
Describe a multicore system
Each CPU can have multiple internal cores each with its own private L1/L2 cache, a shared LLC and DRAM
41
T/F: It makes sense to schedule tasks on CPUs close to memory holding their state?
True! Keeps the cache hot
42
What is the scheduling type known as in which we keep tasks on the CPU closest to the memory node where their state is?
NUMA-aware scheduling
43
What is hyperthreading?
CPU support for multiple execution contexts (2)
44
How do we know if a thread is CPU bound or memory bound?
Use historic information like hardware counters that are updated as the processor executes and keep information about various aspects of execution
45
Is CPI a good metric for informing scheduling decisions?
No, its more or less the same across applications