Shortest-Job-First (sJF)Scheduling Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time.(关联到每个进程下次运行的cPU脉冲长度,调度 最短的进程) Two schemes nonpreemptive-once Cpu given to the process it cannot be preempted until completes its CPU burst (非 抢占式调度一一旦进程拥有cPU,它的使用权限只能在该二 cPU脉冲结束后让出 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 生在有比当前进程剩余时间片更短的进程到达时,也称为最 短剩余时间优先调度) SJF is optimal- gives minimum average waiting time for a given set of processes.(SJF是最优的一对一组指定的进程而 言,它给出了最短的平均等待时间) Applied Operating System Concepts 6.11 Silberschatz, Galvin, and Gagne @1999
6.11 Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts Shortest-Job-First (SJF) Scheduling • Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time.(关联到每个进程下次运行的CPU脉冲长度,调度 最短的进程) • Two schemes: – nonpreemptive – once CPU given to the process it cannot be preempted until completes its CPU burst(非 抢占式调度– 一旦进程拥有CPU,它的使用权限只能在该 CPU 脉冲结束后让出). – 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.(SJF是最优的 – 对一组指定的进程而 言,它给出了最短的平均等待时间)
Example of Non-Preemptive SJF Process Arrival Time Burst Time 0.0 2 4 4.0 4 50 °SJF( non-preemptive) 3 0 78 16 e Average waiting time =(0+6+3+7)74-4 Applied Operating System Concepts 6.12 Silberschatz, Galvin, and Gagne @1999
6.12 Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 • SJF (non-preemptive) • Average waiting time = (0 + 6 + 3 + 7)/4 - 4 Example of Non-Preemptive SJF P1 P3 P2 0 3 7 16 P4 8 12