Lecture 6 - Scheduling Flashcards
Why do processes require scheduling?
Bursts of CPU usage alternate with I/O wait
Some processes CPU-bound, others I/O bound
Prevent one program blocking others from executing
What is the Job queue?
Set of all the processes in the system
What is the ready queue?
Set of all processes in memory, ready to execute
What are device queues?
Sets of processes waiting for an I/O device
What are the goals of scheduling for all systems?
Fairness: give each process a fair share of the CPU
Enforcement: ensure the stated policy is carried out
Balance: keep all parts of the system busy
What are the goals of scheduling for batch systems?
Throughput - maximise jobs per unit time
Turnaround time: minimize wait time for jobs
CPU Utilisation: keep CPU as busy as possible
What are the goals of scheduling for interactive systems?
Response time: respond quickly to user’s requests
Proportionality: meet user’s expectations
What are the goals of scheduling for real time systems?
Meet deadlines - missing deadlines is a system failure
Predictability - same type of behaviour for each time slice
What is the difference between long term, medium term and short term schedulers?
Long term - selects which processes should be brought into ready queue, invoked infrequently (seconds or minutes), slow, controls degree of multiprogramming
Medium term scheduler - swaps out processes temporarily, controls number of jobs in memory, balances load for better throughput
Short term - selects which process should execute next and allocates CPU, fast
What is the difference between cooperative and pre-emptive scheduling?
Co-Operative: process runs until it drops or blocks
Pre-emptive: process interrupted by OS and moved to ready state
In a thread-aware operating system what does the scheduler schedule?
What must it realize to do this efficiently?
Threads - processes are just containers for threads
Context switch for threads from different processes is more expensive
Rescheduling threads onto a different CPU is more expensive - CPU cache might be taken by another thread’s cache
When does a scheduler make decisions?
When the current process changes state from running
Can be due to interrupt by timer
How does First Come First Served scheduling work?
Whats the problem with it?
Do jobs in the order they arrive
Very simple algorithm
BUT Some processes might have to wait if a very long job is busy executing
How does shortest job first scheduling work? How is it different to Shortest Time Remaining?
Do the shortest job first.
Shortest time remaining is a preemptive form, i.e. after interrupt check which shortest remaining job is
What is the problem with shortest job first scheduling?
How does the scheduler know how long a job has left?
How does Round Robin scheduling work?
Give each process fixed time slot,
rotate in order through ready processes,
each process makes a bit of progress
Whats the difficulty with round robin scheduling?
Choosing a good quantum (timespan)
Too long - poor response
Too short - too many context switches
How does lottery scheduling work?
Each process has “tickets” for cpu time
Each quantum, cpu picks a ticket at random, hence, more tickets = more likely to get cpu time
Tickets can be transferred especially between cooperating processes
How does priority queue scheduling work?
Each job has priority associated with it, indicating how important it is
Highest priority jobs run first
Pre-emptive so equal priority jobs share time round robin style
How can priority systems become significantly more flexible?
Allow OS to change priorities of jobs on the fly
What is Decay-Usage scheduling?
Dynamic priority adjusting scheme:
waiting threads have priority increased each quantum
running threads have priority decreased each quantum
What is multilevel queue scheduling?
Each queue has its own scheduling algorithm
E.g. separate system processes, interactive processes, batch, favored, unfavored processes into their own queues
What is a real time system?
Where the correctness of the system depends on when the results are produced
Tasks or processes attempt to control or react to events in the outside world
e.g. control of lab experiments, robotics, air traffic control, telecommunications, military command…
What is the difference between Hard deadlines and soft deadlines?
Hard: disastrous if missed
Validation essential
Soft deadline: ideally should be met, performance degrades in case of missed deadline
Best effort approaches