Lecture 7
Lecture 7
Scheduling Criteria
Scheduling Algorithms
First-come, First-Served
Shortest-Job-First
Priority scheduling
Round Robin
SHORT-TERM
LONG-TERM MID-TERM
Ready Running
Blocked
preemptive scheduling
follow clock interrupts (ex: 50Hz) to forcibly switch processes (change the “Running”
to “Ready”)
Ready Running
Blocked
Priority Scheduling
Priority Scheduling
P1 P2 P3
0 24 27 30
P2 P3 P1
0 3 6 30
Nonpreemtive
If short process are after long process
A
Arrival times B
C
D
E
A B C D E Mean
Priority Scheduling
SJF is optimal
Gives minimum average waiting time for a given
set of processes
The difficulty is knowing the length of the next
CPU request
P4 P1 P3 P2
0 3 9 16 24
=1
n+1 = tn
Only the actual last CPU burst counts
n 1 t n 1 n .
2. n 1 predicted value for the next CPU burst
3. , 0 1
4. Define :
Priority Scheduling
Problem Starvation
low priority processes may never execute
Solution Aging
as time progresses increase the priority of the process
Priority Scheduling
Each process gets a small unit of CPU time (time quantum ), usually
10-100 milliseconds.
After this time has elapsed, the process is preempted and added
to the end of the ready queue.
If there are n processes in the ready queue and the time quantum is q,
then each process gets 1/n of the CPU time in chunks of at most q time
units at once.
No process waits more than (n-1)q time units.
Performance
q large FIFO
q small q must be large with respect to context switch,
otherwise overhead is too high
A B C D E Mean
A B C D E Mean