【文章內(nèi)容簡(jiǎn)介】
+(1 ? )j ? tn 1 + … +(1 ? )n=1 tn ?0 ? Since both ? and (1 ?) are less than or equal to 1, each successive term has less weight than its predecessor. Scheduling algorithms: SJF Scheduling algorithms: SJF ? The SJF scheduling algorithm is provably optimal. ? The SJF scheduling algorithm supports both preemptive and nonpreemptive scheduling algorithms. ? Suitable for longterm scheduling. ? Not very good for shortterm scheduling. ? Difficult to estimate the CPU bursts. Scheduling algorithms: Priority scheduling(最優(yōu)先行 ) Process Burst Time Priority P1 10 3 P2 1 1 P3 2 4 P4 1 5 P5 5 2 Priority scheduling Waiting time: (6+0+16+18+1)/5 =(ms). Scheduling algorithms: Priority scheduling ? A priority number (integer) is associated with each process. ? The CPU is allocated to the process with the highest priority (smallest integer ? highest priority). ? Preemptive. ? Nonpreemptive. ? SJF is a priority scheduling where priority is the predicted next CPU burst time. ? Problem: Starvation (饑餓 ) – low priority processes may never execute. ? Solution: Aging (時(shí)效 ) – A process will increase its priority with time. Scheduling algorithms: RR (循環(huán)而行 ) ? Each process gets a small unit of CPU time (time quantum, 時(shí)間片段 ), usually 10100 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 (n1)q time units. ? Performance ? q large ? FIFO ? q small ? q must be large with respect to context switch time, otherwise overhead is too high. Scheduling algorithms: RR (q=20ms) Process Burst Time P1 53 P2 17 P3 68 P4 24 ? The Gantt chart is: ? Typically, higher average turnaround than SJF, but better response. P1 P2 P3 P4 P1 P3 P4 P1 P3 P3 0 20 37 57 77 97 117 121 134 154 162 Scheduling algorithms: RR (Turnaround time) Scheduling algorithms: RR(Context Switches) Scheduling algorithms: Multilevel queue ? Ready queue is partitioned into separate queues: foreground (inter