操作系统第3次作业_第1页
操作系统第3次作业_第2页
操作系统第3次作业_第3页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

n 1. A CPU scheduling algorithm determines an order for the execution of its scheduled processes. Given n processes to be scheduled on one processor, how many possible different schedules are there? Give a formula in terms of n.答:共有n!=n*(n-1)*(n-2)*1种不同调度方法。n 2. Define the difference between preemptive and nonpreemptive scheduling. State why strict nonpreemptive scheduling is unlikely to be used in a computer center.答:非抢占式调度:一旦CPU被分配给一个进程,那么该进程会一直使用CPU直到进程终止或切换到等待状态时主动释放CPU。可抢占式调度:当一个进程在CPU上运行时,该程序的CPU使用权可以被另一个新进程剥夺,被抢占的程序的状态被保存在PCB中,并进入就绪队列,等待下一次运行。如果一个系统采用的是非可抢占式调度,并采用优先级调度,那么优先级比较低的进程可能永远都在等待被执行,造成饥饿。这种情况就需要采用老化技术来防止饥饿。因此一个计算机中心最好不要采用严格的非抢占式调度。n 3. Consider the following set of processes, with the length of the CPU-burst time given in milliseconds: n The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time 0.n a. Draw four Gantt charts illustrating the execution of these processes using FCFS, SJF, a nonpreemptive priority (a smaller priority number implies a higher priority), and RR (quantum = 1) scheduling.n b. What is the turnaround time of each process for each of the scheduling algorithms in part a?n c. What is the waiting time of each process for each of the scheduling algorithms in part a?n d. Which of the schedules in part a results in the minimal average waiting time (over all processes)? 答:a)P1P2P3P4P501011131419FCFS P1P2P3P4P504 19219非抢占式SJF P1P2P3P4P506 1161819非抢占式优先级 P1 P2 P3 P4 P5 P1 P3 P5 P1 P5 P1 P5 P1 P5 P1 P1 P1 P1 P10 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19RR(时间片=1) b)周转时间:FCFS: P1=10;P2=11;P3=13;P4=14;P5=19; SJF: P1=19;P2=1; P3=4; P4=2; P5=9; 非抢占式优先级: P1=16;P2=1; P3=18; P4=19; P5=6; RR: P1=19;P2=2; P3=7; P4=4; P5=14; c)等待时间:FCFS: P1=0;P2=10;P3=11;P4=13;P5=14; SJF: P1=9;P2=0; P3=2; P4=1; P5=4; 非抢占式优先级: P1=6;P2=0; P3=16; P4=18; P5=1; RR: P1=9;P2=1; P3=5; P4=3; P5=9; d)平均等待时间:FCFS: (0+10+11+13+14)/5=9.6 SJF: (9+0+2+1+4)/5=3.2 非抢占式优先级: (6+0+16+18+1)/4=10.25 RR: (9+1+5+3+9)/4=6.75 所以,SJF算法的平均等待时间最少。n 4. Suppose that the following processes arrive for execution at the times indicated. Each process will run the listed amount of time. In answering the questions, use nonpreemptive scheduling and base all decisions on the information you have at the time the decision must be made. n a. What is the average turnaround time for these processes with the FCFS scheduling algorithm?n b. What is the average turnaround time for these processes with the SJF scheduling algorithm?n c. The SJF algorithm is supposed to improve performance, but notice that we chose to run process P1 at time 0 because we did not know that two shorter processes would arrive soon. Compute what the average turnaround time will be if the CPU is left idle for the first 1 unit and then SJF scheduling is used. Remember that processes P1 and P2 are waiting during this idle time, so their waiting time may increase. This algorithm could be known as future-knowledge scheduling

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论