P3L1 Flashcards
(47 cards)
3 Options for scheduler
- Assign tasks immediately (FCFS)
- Assign simple tasks first (SJF)
- Assign complex tasks first
FCFS
First Come First Serve (FIFO)
SJF
Shortest Job First
CPU Scheduler runs when
- CPU become idles
- New tasks become ready
- timeslice expired timeout
runqueue is equal to
scheduling algorithm
“Run-to-completion” scheduling
No preemption
Metrics for schedulers
throughput
avg job completion time
avg job wait time
cpu utilization
Data structure for FCFS
Queue
Data structure for SJF
Ordered queue or tree
SJF + Preemption
heuristics based on history -> job running time
Priority Scheduling
Run highest priority next
Data structure(s) for Priority Scheduling
Queues for each priority
Tree with priority
How to deal with Priority Scheduling Starvation
priority aging function (actual priority, time spent in run queue)
What is Priority Invesion
Priorities inverted due to lock
Solution to Priority Inversion
Temp boost priority of mutex owner, lower on release
Round Robin Scheduing
Pick up first task from queue (task only yields to wait on I/O)
Round Robin w/ Priorities
Include preemption
Round Robin w/ interleaving
Timeslicing
Timeslice
(aka Time Quantum)
maximum amount of uninterrupted time given to a task
Advantages of timeslice
- Shorter tasks finish first
- More responsive
- Lengthy I/O ops initiated sooner
Timeslice needs to be much greater than
context switch
CPU bound tasks prefer
larger timeslices
I/O Bound tasks prefer
smaller timeslices
CPU Bound Timeslices
higher timeslices
a) limits context switching overheads
b) keeps CPU utilization and throughput high