CPUSch
CPUSch
Scheduling
Introduction
0 24 27 30
• Waiting time for P1 = 0; P2 = 24; P3 = 27
• Average waiting time: (0 + 24 + 27)/3 = 17
FCFS Scheduling (Cont.)
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
Example of Non-Preemptive SJF
0 3 7 8 12 16
0 2 4 5 7 11 16
P1 P2 P3 P4 P1 P3 P4 P1 P3 P3