Multitasking and Scheduling Flashcards
(43 cards)
What are the three possible states of a process?
Ready, running and Blocked
What does the scheduler decide
“The scheduler decides which process from the set of ready processes will get the CPU next”
What is a context switch
A context switch is the name given when one process stores its state and “yeilds” for another process to execute
What are the two reasons a context switch may take place
Pre-emptive switching where the OS choses to switch between processes
Interrupt driven switching where Hardware of Software Interrupts trigger a switch between processes
What is the main issue with Context Switching
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
What does the quantum in round-robin scheduling describe
The allowance of CPU time one process gets in one cycle
What are the tradeoffs between Short and Long Quantum in round-robin scheduling
Long Quantum:
+ Long response time
+ Good Efficiency
Short Quantum:
+ Fast response time
+ High overhead from context switching
What is the large drawback of lottery scheduling
There are no guarantees that a given process will get CPU timed as it uses random ticket selection
What are the two different approaches to deadlines for real-time systems
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
What are the key features of RIOS
+ Minimalist but practical
+ Fixed priorites
+ Preemptive multitasking
+ Bounded stack usage
+ Small and understandable
Where do tasks execute when scheduling with RIOS
Within interupt service routines
What must we be careful about calling within RIOS tasks
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.
What is the deadline of a task
The latest time by which a task has to be completed
What does it mean for a task to be periodic
It means that the task repeats itself at a regular interval of time
What does it mean for a task to be aperiodic
It means that the task does have a regular interval of time between when it needs to be ran
How can CPU Utilization be calculated (U), and what constraint always exists on this
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
What assumptions are made when analysing the scheduling of tasks
- Tasks are periodic
- The deadline for a task is its next invocation
- Context switches take no time
When analysing the scheduling of tasks, how do we handle Aperiodic tasks
We use polling, and assume the worst case for every tick
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
U=∑ni=1ci / pi
This U value must be less than 1 for the system to be schedulable
What two methods can we use to assign priority to tasks
Fixed (static) priority which is assigned at compile time
Dynamic priority which changes during runtime
What is the advantage of Fixed Priority scheduling over Dynamic Priority scheduling
Fixed Priority has very simple code, and is well understood meaning we can have high confidence in its behaviour
What is the optimal priority scheme for fixed priority scheduling
Rate Monotonic Scheduling
What are the requirements for Rate Monotonic Scheduling
Tasks are independent
Tasks have fixed CPU requirement
Context switching is free
Deadline of a given task is its period
For RMS tasks must be independent
No task can block another task