中科大操作系统原理与实现课件5_CPU_Scheduling0.pdf
《中科大操作系统原理与实现课件5_CPU_Scheduling0.pdf》由会员分享,可在线阅读,更多相关《中科大操作系统原理与实现课件5_CPU_Scheduling0.pdf(53页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、.操作系统原理与设计第5章 CPU Scheduling(1)陈香兰中国科学技术大学计算机学院2009年09月01日.CPU scheduling is the basis of multiprogrammed OSes.提纲CPU scheduling(1).Basic ConceptsCPU-I/O Burst CycleCPU SchedulerPreemptive SchedulingDispatcherScheduling CriteriaScheduling CriteriaScheduling AlgorithmsFCFS SchedulingSJF SchedulingPrio
2、rity SchedulingRound Robin SchedulingMultilevel Queue SchedulingMultilevel Feedback Queue Scheduling小结和作业.Objective of multiprogrammingIMaximum CPU utilization.Outline.Basic ConceptsCPU-I/O Burst CycleCPU SchedulerPreemptive SchedulingDispatcherScheduling CriteriaScheduling CriteriaScheduling Algori
3、thmsFCFS SchedulingSJF SchedulingPriority SchedulingRound Robin SchedulingMultilevel Queue SchedulingMultilevel Feedback Queue Scheduling小结和作业.CPU-I/O Burst Cycle IIA property of process:CPU-I/O Burst CycleIProcess execution consists of a cycleof CPU execution and I/O waitIProcess execution=n(CPU ex
4、ecution+I/O wait)IAlternating Sequence of CPU And I/OBursts.CPU-I/O Burst Cycle IIICPU burst distributionIHistogram of CPU-burst Times.Outline.Basic ConceptsCPU-I/O Burst CycleCPU SchedulerPreemptive SchedulingDispatcherScheduling CriteriaScheduling CriteriaScheduling AlgorithmsFCFS SchedulingSJF Sc
5、hedulingPriority SchedulingRound Robin SchedulingMultilevel Queue SchedulingMultilevel Feedback Queue Scheduling小结和作业.CPU SchedulerICPU scheduler(Short-term Scheduler)ISelects from among the processes in memory that are ready toexecute,and allocates the CPU to one of themIReady Queue:IFIFO Queue?Iby
6、 priority?Itree?Iunordered linked list?.Outline.Basic ConceptsCPU-I/O Burst CycleCPU SchedulerPreemptive SchedulingDispatcherScheduling CriteriaScheduling CriteriaScheduling AlgorithmsFCFS SchedulingSJF SchedulingPriority SchedulingRound Robin SchedulingMultilevel Queue SchedulingMultilevel Feedback
7、 Queue Scheduling小结和作业.Preemptive Scheduling IICPU scheduling decisions may take place when a process:1.Switches from running to waiting state2.Switches from running to ready state3.Switches from waiting to ready4.TerminatesIThe scheduling scheme:Inonpreemptive:only 1&4IWindows 3.xIbefore Mac OS XIo
8、therwise preemptive(usually needs a hardware timer,synchronization overhead)IWindows 95&.IMac OS X.Preemptive Scheduling IIpreemptive kernel VS.nonpreemptive kernel?Interrupt affected code VS normal kernel code?.Outline.Basic ConceptsCPU-I/O Burst CycleCPU SchedulerPreemptive SchedulingDispatcherSch
9、eduling CriteriaScheduling CriteriaScheduling AlgorithmsFCFS SchedulingSJF SchedulingPriority SchedulingRound Robin SchedulingMultilevel Queue SchedulingMultilevel Feedback Queue Scheduling小结和作业.DispatcherIDispatcher module gives control of the CPU to the processselected by the short-term scheduler;
10、this involves:Iswitching contextIswitching to user modeIjumping to the proper location in the user program to restartthat programIDispatch latency time it takes for the dispatcher to stopone process and start another runningImust be short.Dispatch latency.Outline.Basic ConceptsCPU-I/O Burst CycleCPU
11、 SchedulerPreemptive SchedulingDispatcherScheduling CriteriaScheduling CriteriaScheduling AlgorithmsFCFS SchedulingSJF SchedulingPriority SchedulingRound Robin SchedulingMultilevel Queue SchedulingMultilevel Feedback Queue Scheduling小结和作业.Scheduling Criteria IICPU utilization(CPU 利用率)keep the CPU as
12、 busy aspossibleIconceptually:0%100%Iin a real system:40%90%IThroughput(吞吐率)#of processes that complete theirexecution per time unitIdifferent from one process set to another process setIfor long processes:may be 1 process per hourIfor short transactions:may be 10 processes per secondITurnaround tim
13、e(周转时间)amount of time to execute aparticular processIfrom the time of submission of a process to the time ofcompletion=the periods spent waiting to get into memory,waiting in theready queue,executing on the CPU,and doing I/O.Scheduling Criteria IIIWaiting time amount of time a process has been waiti
14、ng inthe ready queueIResponse time amount of time it takes from when arequest was submitted until the first response is produced,notoutput(for time-sharing environment).Optimization CriteriaIMaximize?ICPU utilizationIthroughputIMinimize?Iturnaround timeIwaiting timeIresponse timeIAverage?IStability?
15、different from system to system.Outline.Basic ConceptsCPU-I/O Burst CycleCPU SchedulerPreemptive SchedulingDispatcherScheduling CriteriaScheduling CriteriaScheduling AlgorithmsFCFS SchedulingSJF SchedulingPriority SchedulingRound Robin SchedulingMultilevel Queue SchedulingMultilevel Feedback Queue S
16、cheduling小结和作业.FCFS SchedulingIFirst-Come,First-ServedInonpreemptiveIImplementation:INormal Queue:FIFO QueueIordered by request timeIlinked listIInsert:linked to the tail of the queueIscheduling:removed from the head of the queue.Example of FCFS Scheduling.ISuppose that the processes arrivein the or
17、der:P1,P2,P3The Gantt Chart for the schedule is:ProcessBurstTime(ms)P124P23P33IWaiting time for P1=0;P2=24;P3=27IAverage waiting time:(0+24+27)/3=17.Example of FCFS Scheduling II.ISuppose that the processes arrivein the orderP2,P3,P1IThe Gantt chart for the schedule is:ProcessBurstTime(ms)P124P23P33
18、IWaiting time for P1=6;P2=0;P3=3IAverage waiting time:(6+0+3)/3=3IMuch better than previous case.Convoy effectIexample situation:Ione CPU-bound processImany I/O-bound processesIConvoy effect(护航效应;护卫效应):Iall the other processes wait for the one big process to get offthe CPUIshort process behind long
19、process.Outline.Basic ConceptsCPU-I/O Burst CycleCPU SchedulerPreemptive SchedulingDispatcherScheduling CriteriaScheduling CriteriaScheduling AlgorithmsFCFS SchedulingSJF SchedulingPriority SchedulingRound Robin SchedulingMultilevel Queue SchedulingMultilevel Feedback Queue Scheduling小结和作业.SJF Sched
20、ulingIShortest-Job-First(shortest-next-CPU-burst algorithm)IAssociate with each process the length of its next CPUburst.IUse these lengths to schedule the process with the shortesttime.SJF scheduling example.ProcessBurstTime(ms)P16P28P37P43IThe Gantt chart for the schedule is:IWaiting time for P1=3;
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 中科大 操作系统 原理 实现 课件 _CPU_Scheduling0
限制150内