时间片轮转调度算法RoundRobinEachprocess gets a smallunitofCPUtime(timeslice),usually10-100milliseconds.After this timehaselapsed, theprocessispreempted and added totheend of the ready queue.If there are n processes intheready queue and thetime sliceisg,theneachprocessgets 1/noftheCPUtime in chunks of at most g time units at once. Noprocess waits more than (n-1)gtime unitsPerformanceqlarge=FIFOqsmall=gmustbelargewithrespecttocontextswitchotherwiseoverheadistoohigh
时间片轮转调度算法Round Robin Each process gets a small unit of CPU time (time slice), usually 10-100 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 slice 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 (n-1)q time units. Performance − q large FIFO − q small q must be large with respect to context switch, otherwise overhead is too high
Example ofRRwith Time Slice=1时间片为1时的例子ServiceArrivalTimeTimeProcessP1P2P3P4P51501020Round-Robin(RR), q = 1P1P2P3P4P5
Example of RR with Time Slice= 1 时间片为1时的例子 Process Arrival Time Service Time P1 P2 P3 P4 P5
Time Quantum and Context Switch Time时间片的选择与进程转换时间timeslice(quantum数量/定量)processtime=10contextquantumswitches12001060106A9670234589101
Time Quantum and Context Switch Time 时间片的选择与进程转换时间 time slice( quantum 数量/定量)
时间片的选择mustbesubstantially(充分的)largerthanthetimerequiredtohandletheclockinterruptanddispatching(调度)should be largerthenthetypicalinteraction(butnot muchmore toavoidpenalizing(不利于)//Oboundprocesses)Process allocatedInteractiontime quantumcompleteTimeVZTimequantumgreaterthan时间片大于典型typicalinteraction的交互时间响应时间Responsetime9-s时间片QuantumqProcess allocated被抢占ProcessProcessallocated Interactiontime quantumpreemptedtime quantumcompleteTimequantumlessthantypicalinteraction时间片小于典型Otherprocessesrunq的交互时间
时间片的选择 must be substantially(充分的) larger than the time required to handle the clock interrupt and dispatching(调度) should be larger then the typical interaction (but not much more to avoid penalizing(不利于) I/O bound processes) 时间片 响应时间 被抢占 时间片大于典型 的交互时间 时间片小于典型 的交互时间
时间片的选择时考虑的因素系统对响应时间的要求就绪队列中进程的数目系统的处理能力
时间片的选择时考虑的因素 系统对响应时间的要求 就绪队列中进程的数目 系统的处理能力