Chapter 5: Process Scheduling
Chapter 5: Process Scheduling
Administrative
P1 P2 P3
0 24 27 30
Waiting time for P1 = 0; P2 = 24; P3 = 27
Average waiting time: (0 + 24 + 27)/3 = 17
P2 P3 P1
0 3 6 30
Associate with each process the length of its next CPU burst. Use
these lengths to schedule the process with the shortest time
Two schemes:
nonpreemptive – once CPU given to the process it cannot be
preempted until completes its CPU burst
preemptive – if a new process arrives with CPU burst length
less than remaining time of current executing process,
preempt. This scheme is know as the
Shortest-Remaining-Time-First (SRTF)
SJF is optimal – gives minimum average waiting time for a given
set of processes
0 3 7 8 12 16
P1 P2 P3 P2 P4 P1
0 2 4 5 7 11 16
P1 P3 P2 P4
0 3 7 8 12 16
Average waiting time = (0 + 6 + 3 + 7)/4 = 4
P1 P2 P3 P2 P4 P1
0 2 4 5 7 11 16
Average waiting time = (9 + 1 + 0 +2)/4 = 3
P1 P2 P3 P4 P1 P3 P4 P1 P3 P3
Bài tập
P1 0 20
P2 1 5
P3 2 3
P4 12 6
CPU
P1 P2 P1 P3 P2 P3 P1 P3
0 2 3 6 10 13 14 15 17 21
R1 P2 P1 P2
3 13 15 19
R2 P1 P3
27 17 19 21 22
Operating System Principles 5.27 Silberschatz, Galvin and Gagne ©2005
28
Assume m processes
Each process runs periodically
Process i needs Ci time to finish
Pi: period duration for process i
Necessary condition for all processes
finish on time:
A A1 A2 A3 A4
B B1 B2 B3
C C1 C2 C3
RMS A1 B1 C1 A2 B2 C2 A3 B3 A4 C3
EDF A1 B1 C1 A2 B2 C2 A3 B3 A4 C3
0 10 20 30 40 50 60 70 80 90 100 110
A A1 A2 A3 A4
B B1 B2 B3
C C1 C2 C3
RMS A1 B1 A2 B2 Failed
EDF A1 B1 C1 A2 B2 A3 C2 B3 A4 C3
0 10 20 30 40 50 60 70 80 90 100 110
Solaris scheduling
Windows XP scheduling
Linux scheduling