Documente Academic
Documente Profesional
Documente Cultură
Metrics
0 6 14 21 24
Priority Scheduling
A Problem with Preemptive SJF
Each job is assigned a priority.
Starvation FCFS within each priority level.
A job may keep getting preempted Select highest priority job over lower
by shorter ones ones.
Example Rationale: higher priority jobs are more
Process A with elapse time of 1 hour arrives at time 0
mission-critical
But every 1 minute, a short process with elapse time
of 2 minutes arrives Example: DVD movie player vs. send email
Result of SJF: A never gets to run Problems:
What’s the difference between starvation May not give the best AWT
and deadlock? 17
Starvation of lower priority processes 18
Priority Scheduling: Example Set Priority
(Lower priority number is more preferable)
Process Duration Priority Arrival Time Every process has a default priority
P1 6 4 0
P2 8 1 0 User can also change a process priority
P3 7 3 0
P4 3 2 0 The nice command to change process’ priority
Do it yourself
P2 (8) P4 (3) P3 (7) P1 (6)
0 8 11 18 24
P2 waiting time: 0
P4 waiting time: 8
The average waiting time (AWT):
P3 waiting time: 11 (0+8+11+18)/4 = 9.25
P1 waiting time: 18 (worse than SJF)
19 20
21 22