Multitasking and Scheduling Flashcards

1
Q

What are the three possible states of a process?

A

Ready, running and Blocked

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

What does the scheduler decide

A

“The scheduler decides which process from the set of ready processes will get the CPU next”

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

What is a context switch

A

A context switch is the name given when one process stores its state and “yeilds” for another process to execute

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

What are the two reasons a context switch may take place

A

Pre-emptive switching where the OS choses to switch between processes
Interrupt driven switching where Hardware of Software Interrupts trigger a switch between processes

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

What is the main issue with Context Switching

A

It has overhear, for a context switch to occur it needs to:

+ Save/restore program counter
+ Save/restore stack register(s)
+ Save/restore status register
+ Save/restore general purpose registers
+ Save/restore memory map
+ Save/restore I/O status ← outstanding requests
+ Invalidate Memory Cache
+ Invalidate Working set of pages

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

What does the quantum in round-robin scheduling describe

A

The allowance of CPU time one process gets in one cycle

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

What are the tradeoffs between Short and Long Quantum in round-robin scheduling

A

Long Quantum:
+ Long response time
+ Good Efficiency
Short Quantum:
+ Fast response time
+ High overhead from context switching

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

What is the large drawback of lottery scheduling

A

There are no guarantees that a given process will get CPU timed as it uses random ticket selection

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

What are the two different approaches to deadlines for real-time systems

A

Soft real-time systems such as multimedia controllers where its acceptable to be slightly off
Hard real-time systems where it’s not ok to be off at all

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

What are the key features of RIOS

A

+ Minimalist but practical
+ Fixed priorites
+ Preemptive multitasking
+ Bounded stack usage
+ Small and understandable

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

Where do tasks execute when scheduling with RIOS

A

Within interupt service routines

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

What must we be careful about calling within RIOS tasks

A

We must be careful about calling non-rentrant functions within RIOS tasks, as these may be interrupted.

Say we need to use printf() in multiple places, we should create our own task which prints from a queue and is the only task using printf(), and then any function which wish to print should push to this.

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

What is the deadline of a task

A

The latest time by which a task has to be completed

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

What does it mean for a task to be periodic

A

It means that the task repeats itself at a regular interval of time

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

What does it mean for a task to be aperiodic

A

It means that the task does have a regular interval of time between when it needs to be ran

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

How can CPU Utilization be calculated (U), and what constraint always exists on this

A

U=Ctotal - Cidle <= 1

Where
- Ctotal is the total CPU time available, such as 100%
- Cidle is the Fraction of CPU time spent in idle task or sleeping

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

What assumptions are made when analysing the scheduling of tasks

A
  1. Tasks are periodic
  2. The deadline for a task is its next invocation
  3. Context switches take no time
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

When analysing the scheduling of tasks, how do we handle Aperiodic tasks

A

We use polling, and assume the worst case for every tick

19
Q

Given a set of tasks T1…Tn with periodicity pi and fixed CPU time ci for task i, how do we calculate the load (U) of this set of tasks. And when are these tasks schedulable

A

U=∑ni=1ci / pi

This U value must be less than 1 for the system to be schedulable

20
Q

What two methods can we use to assign priority to tasks

A

Fixed (static) priority which is assigned at compile time

Dynamic priority which changes during runtime

21
Q

What is the advantage of Fixed Priority scheduling over Dynamic Priority scheduling

A

Fixed Priority has very simple code, and is well understood meaning we can have high confidence in its behaviour

22
Q

What is the optimal priority scheme for fixed priority scheduling

A

Rate Monotonic Scheduling

23
Q

What are the requirements for Rate Monotonic Scheduling

A

Tasks are independent
Tasks have fixed CPU requirement
Context switching is free
Deadline of a given task is its period

24
Q

For RMS tasks must be independent

A

No task can block another task

25
Q

for RMS tasks must have a fixed CPU requirement, what do we do if a task has a variable CPU requirement

A

We assume it to take the worst-case amount of time

26
Q

For RMS we assume context switching to be free (when its not), how do we get around this

A

We include the time taken to context switch in the task time

27
Q

How do we assign the fixed priorities for RMS

A

We give the most frequent task the highest priority

28
Q

What must U=∑ni=1ci / pi be less than for RMS to be able to guarantee scheduling for

A

ni=1ci / pi must be less than n(21/n-1)

29
Q

As n approaches infinity, what can we approximate the upper bound for RMS to be effective as

A

69%

30
Q

When assigning priority for RMS, what does a priority of 0 mean

A

0 means that the task is of the highest priority

31
Q

Assign the priority for the following tasks with RMS:

  • Task A, Importance: Very High, Frequency: 2Hz
  • Task B, Importance: High, Frequency: 0.5Hz
  • Task C, Importance: Medium, Frequency: 50Hz
A

Priority:
C: 0 (Highest)
A: 1
B: 2

32
Q

RMS is effective when U<=69% (generalisation but diligaf), what can be done such that we don’t “waste” the other 30% of CPU time

A

We can either use it to run non-real-time tasks with a “low priority” or optimise the task periods such that a regular execution pattern is achieved

33
Q

If tasks are harmoic, what can we guarantee after observing one successful period of tasks

A

That all future periods will take the same form

34
Q

How do we make a given task set harmonic

A

Reduce the deadlines of tasks (make the deadlines stricter) such that any task period is a multiple of the period of any higher priority task

35
Q

For a set of tasks T, with task periods pi, what must hold for the task set to be harmonic

A

For each task ti in T
- For every other task tj in T / {ti}
- pj < pi or pj=pi * n given n is taken from the set of natural numbers

36
Q

Give one example restriction which would make the following periods harmonic
1. 17ms
2. 31ms
3. 130ms

A
  1. 15ms
  2. 30ms
  3. 120ms
37
Q

What CPU utilization can be reached with a harmonic task set

A

100% Utilization

38
Q

What do we use instead of periods for Dynamic Priority Scheduling

A

We use Deadlines in place of periods, this is useful if the deadline is earlier than the next period

39
Q

What is EDF and how does it work

A

Earliest Deadline First allows dynamic changes of priority and runs the most urgent task first
This can allow preemtion

40
Q

What can we use to calculate the U value for EDF

A

U= ∑ni=1ci/pi ≤ 1
Where ci is the CPU time needed to complete the task and pi is the period of the task

41
Q

What are some of the drawbacks of using EDF in place of RMS

A

The Scheduler is more complicated
The Scheduler has more overhead
EDF is not stable under overload

42
Q

What can EDF handle which RMS cannot

A

+ Changing the importance of tasks
+ New tasks at runtime
+ Variable execution time

43
Q
A