slides 12 - Scheduling Flashcards
CPU scheduler
When CPU becomes idle, it selects next job from ready queue
CPU Dispatcher
- Swaps processes
- Steps:
1. Switch context from one process to another
2. Switch to user mode
3. Jump to proper location in user program and resume
Preemptive vs non-preemptive
- Preemptive: running process can be interrupted
- Non-preemptive: any new process must wait for running process to finish CPU cycle
Preemptive vs non-preemptive examples (2 each)
PREEMPTIVE
1. process switches running -> ready
2. process switches waiting -> ready
NON-PREEMPTIVE
1. process switches running -> waiting
2. process terminates
CPU utilization
capacity used/total capacity
Efficiency
useful work/total work
Throughput
number of processes completed per unit time
Turnaround time
Interval from submission to completion of a process
Waiting time
Sum of periods spent in ready queue
Response time
Time from submission to time the request got the first response - start of response is taken
Estimating runtime of jobs (formula)
First-come, first-served scheduling
- Jobs that arrives first is given CPU first
- Convoy effect: if we have a lot of I/O bound processes waiting on I/O and a CPU bound process gets on the CPU first, its going to hold the CPU for a long time and the IO processes will have to wait in the ready queue for a long time
Shortest-job-first scheduling
- Non-preemptive
- Assume a set of jobs have already arrived and in ready queue
- Select job with shortest burst size
- Minimal average waiting time
Shortest remaining time next scheduling
- Preemptive
- Selects job with smallest REMAINING burst size
Round-robin scheduling
- Has a quantum (time slice): length before preemption of a process
- Ready queue is a circular queue
- If executing process has more time -> goes back to ready queue
- If executing process terminates -> select another job
- Benefit: fair - a job gets1/n of the CPU every q time units