完整版操作系统课后重点习题整理文档良心出品_第1页
完整版操作系统课后重点习题整理文档良心出品_第2页
完整版操作系统课后重点习题整理文档良心出品_第3页
完整版操作系统课后重点习题整理文档良心出品_第4页
完整版操作系统课后重点习题整理文档良心出品_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

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

文档简介

1、第一章1.17 Define the essential properties of the following types of operating systems: 列出下列操作系统的基本特点:a. Batch 批处理b. Interactive 交互式c. Time sharing 分时d. Real time 实时e. Network 网络g. Distributed 分布式f. 并行式 h. 集群式 i. 手持式 Answer: 作业 ch1- 第四题(第六版答案)a. Batch相似需求的Job分批、成组的在计算机上执行,Job由操作员或自动Job程序装置装载;可以通过采用 buf

2、fering, off-line operation, spooling, multiprogramming等技术使CPU 和 I/O 不停忙来提高性能批处理适合于需要极少用户交互的 Job。b. Interactive 由许多短交易组成,下一次交易的结果可能不可预知 需要响应时间短c. Time sharing使用CPU调度和多道程序提供对系统的经济交互式使用,CPI快速地在用户之间切换一般从终端读取控制,输出立即打印到屏幕d. Real time 在专门系统中使用,从传感器读取信息,必须在规定时间内作出响应以确保正确的执行e. Network在通用OSh添加联网、通信功能 远程过程调用 文

3、件共享f. Distributed 具有联网、通信功能 提供远程过程调用提供多处理机的统一调度调度统一的存储管理分布式文件系统第二章第六版 2.3 What are the differences between a trap and an interrupt? What is the use of each function?答:作业 ch2- 第二题 (第六版答案) An interrupt 是硬件产生的系统内的流的改变A trap 是软件产生的“中断”。interrupt可以被I/O用来产生完成的信号,从而避免CPU寸设备的轮询A trap可以用来调用OS勺例程或者捕获算术错误第七版 2

4、.3 讨论向操作系统传递参数的三个主要的方法。1. 通过寄存器来传递参数2. 寄存器传递参数块的首地址3. 参数通过程序存放或压进堆栈中,并通过操作系统弹出堆栈。第三章第七版 3.1 论述短期 , 中期和长期调度之间的区别 .a. 短期调度 : 在内存作业中选择就绪执行的作业 , 并为他们分配 CPU。b. 中期调度 : 作为一种中等程度的调度程序, 尤其被用于分时系统, 一个交换方案的实施, 将部分运行程序移出内存,之后,从中断处继续执行。c. 长期调度(作业调度程序) : 确定哪些作业调入内存以执行 . 它们主要的不同之处是它们的执行的频率。短期调度必须经常调用一个新进程,由 于在系统中,

5、长期调度处理移动的作业时,并不频繁被调用,可能在进程离开系统时 才被唤起。第七版 3.2 问 : 描述一下内核在两个进程间进行上下文功换的动作.答:总的来说, 操作系统必须保存正在运行的进程的状态,恢复进程的状态。保存进程的状 态主要包括 CPU 寄存器的值以及内存分配,上下文切换还必须执行一些确切体系结构的操 作,包括刷新数据和指令缓存。(书中答案)进程关联是由进程的PCB来表示的,它包括 CPU寄存器的值和内存管理信息等。当发生上下文切换时,内核会将旧进程的关联状态保存在其PCB中,然后装入经调度要执行的新进程的已保存的关联状态。第五章第七版 5.4 Consider the follow

6、ing set of processes, with the length of the CPU-burst time give n in millisec on ds:(考虑下列进程集, 进程占用的 CPU区间长度以毫秒来计算:)错误 ! 未指定书签。The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all attime 0.(假设在时刻0以进程Pi,P2, P3,P4, P5的顺序到达。)a. Draw four Gantt charts illustrating the execution

7、 of these processes using FCFS, SJF, a nonpreemptive priority (a smaller priority number implies a higher priority), and RR (quantum = 1) scheduling. (画出 4 个 Gantt 图分别演示用 FCFS SJF、非抢占优 先级(数字小代表优先级高)和 RR (时间片=1)算法调度时进程的执行过程。)b. What is the turnaround time of each process for each of the scheduling al

8、gorithms in part a?( 在 a 里每个进程在每种调度算法下的周转时间是多少? )c. What is the waiting time of each process for each of the scheduling algorithmsin part a?( 在 a 里每个进程在每种调度算法下的等待时间是多少? )d. Which of the schedules in part a results in the minimal average waiting time (over all processes)?( 在 a 里哪一种调度算法的平均等待时间对所有进程而言最

9、小? ) 答:作业 ch6- 第三题 第六版 6.4 Suppose that the following processes arrive for execution at the timesindicated. Each process will run the listed amount oftime. In answering thequestions, use nonpreemptive scheduling and base all decisions on the information you have at the time the decision must be made

10、."rritThin0.00 4l.i*a. What is the average turnaround time for these processes with the FCFSscheduling algorithm?b. What is the averageturnaround time for these processes with the SJFschedulingalgorithm?c. The SJF algorithm is supposed to improve performa nee, but no tice that we choseto run pr

11、ocess 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 un it and the n SJF scheduli ng is used. Remember that processesP1 and P2 are wait ing duri ng this idle time, so their wa

12、it ing time may in crease.This algorithm could be known as future-k no wledge scheduli ng.答:a. (8-0)+(12-0.4)+(13-1.0)/3 = 10.53 ;b. (8-0)+(13-0.4)+(9-1.0)/3 = 9.53;c. (14-0)+(6-0.4)+(2-1.0)/3 = 6.87;第六版(理发师)第 4题:The Sleeping-Barber Problem. A barbershop consistsof a waiting room with n chairsand th

13、e barber room containing the barber chair. If there are no customers to beserved, the barber goes to sleep. If a customer enters the barbershop and all chairs are occupied, the n the customer leaves the shop. If the barber is busy but chairs are available, then the customer sits in one of the free c

14、hairs. If the barber isasleep, the customer wakes up the barber. Write a program to coord in atethe barberand the customers.答:作业ch7-第四题理发师和顾客同步,理发师必须由顾客唤醒,理发师给一个顾客理发完,要让理发完的顾客退出,让等待顾客进入,顾客互斥的占用n个位置 /共享变量制约理发师,Snumchair制约顾客semaphore Scuthair, Snu mchair;/ ScuthairScuthair=0; Snu mchair=0;barber:do wa

15、it(Scuthair);/检查是否有顾客,无就睡眠给某个顾客理发sig nal(S nu mchair);/让理发完的顾客退出,让等待的一个顾客进入 while (1);Customer i:wait(S nu mchair);/申请占用椅子signal(Scuthair);/ 给理发师发一个信号 坐在椅子上等着理发 / 共享变量semaphore Scuthair, Mutexchair;/ Scuthair给理发师 , Mutexchair 制约顾客对椅子的互斥占领 int number = 0;/顾客的共享变量,记录已经有的顾客数Scuthair=0; Mutexchair =1;Cu

16、stomer i:wait(Mutexchair);/ 申请对共享变量 number 的操作(申请占用椅子) if(number = = n-1)signal(Mutexchair); exit;给理发师发一个信号申请对共享变量 number 的操作number = number +1; signal(Scuthair);/ signal(Mutexchair);等待理发 理发完毕 wait(Mutexchair);/ number = number -1; signal(Mutexchair);离开理发店barber:do wait(Scuthair);/ 检查是否有顾客,无,就睡眠给某个顾

17、客理发 while (1);第七章第七版 7.5 In a real computer system, neither the resources available nor the demands of processes for resources are consistent over long periods (months).Resources break or are replaced, new processes come and go, new resources are bought and added to the system. If deadlock is contro

18、lled by the banker 's algorithm, which of the following changes can be made safely (without introducing the possibility of deadlock), and under what circumstances?( 在一个真实的计算机系统中,无论是可用 的资源还是进程命令对资源的要求都会持续很长一段时间(几个月) 。资源损坏或被替换, 新的进程进入和离开系统, 新的资源会被购买和添加到系统中。 如果用银行家算法控制死锁, 下面哪些变化是安全的(不会导致可能的死锁),并且在什

19、么情况下发生? )a. Increase Available (new resources added)增加可用资源(新的资源被添加到系统)b. Decrease Available (resource permanently removed from system) 减少可用资源(资 源被从系统中永久性地移出)c. Increase Max for one process (the process needs more resources than allowed,it may want more)增加一个进程的 Max (进程需要更多的资源,超过所允许给予的资源)d. Decrease M

20、ax for one process (the process decides it does not need that manyresources)减少一个进程的 Max (进程不再需要那么多资源)e. Increase the number of processes增加进程的数量f. Decrease the number of processes减少进程的数量答:作业ch8-第二题第七版 7.7Consider a system consisting of m resources of the same type, beingshared by n processes. Resourc

21、es can be requested and released by processes onlyone at a time. Show that the system is deadlock-free if the following two conditions hold:(假设一个系统有m个资源被n个进程共享,进程每次只请求和释放一个资源。证明只要系统符合下面两个条件,就不会发生死锁)a. The maximum n eed of each process is betwee n 1 and m resources(每个进程需要资源的最大值在1到m之间)b. The sum of al

22、l maximum needs is less than m + n(所有进程需要资源的最大值的和小于m+r)答:作业ch8-第三题使用Section7.6.2 的术语,可以有:na. Maxi <m+ni 1b. Maxi > 1 for all iProof:Need = Max - AllocationiIf there exists a deadlock state the n:nC. i 1Allocationi = mUse a. to get:Needi +Allocati oni =Maxi < m + nUse c. to get:Needi + m <

23、; m + nRewrite to get:in 1 Need这意味着存在一个 Pi的进程,其 Need=0.如果 Max>=1,那么Pi进程至少有一个资源可 以释放。从而系统就不会进入死锁状态。第七版 7.11 Consider the following snapshot of a system:H/hu"川 MHABCD0012I ooc13540632ABCD00 1 2ABCD1520Pi0014An swer the follow ing questi ons using the ban ker 答下面的问题)0 6 ? 20 6 5 6's algorit

24、hm:(使用银行家算法回(Need矩阵的内容是怎样的?)a. What is the content of the matrix Need?b. Is the system in a safe state?(系统是否处于安全状态?)c. If a request from process P1 arrives for (0,4,2,0), can the request be gran ted immediately?(如果从进程 P1发出一个请求(0 4 2 0 ),这个请求能否被满足?) 答:作业ch8-第四题a. Need 矩阵的内容是 P0(0 0 0 0 ) P1(0 7 5 0 )

25、 P2(1 0 0 2 ) P3(0 0 2 0 ) P4 (0 6 4 0 )。b. 系统处于安全状态,因为Available 矩阵等于(1 5 2 0 ),进程P0和P3都可以运行,当进程P3运行完时,它释放它的资源,而允许其它进程运行。c. 可以被满足,满足以后, Available 矩阵等于( 1 1 0 0),当以次序 P0, P2, P3, P1 ,P4 运行时候,可以完成运行。第八章第七版 8.3 Given memorypartitions of 100K, 500K, 200K, 300K, and 600K (in order), how would each of the

26、 First-fit, Best-fit, and Worst-fit algorithms place processes of 212K, 417K, 112K, and 426K (in order)?Which algorithm makes the most efficientuse of memory?(按顺序给出 5个部分的内存,分别是100KB,500KB,200KB,300KB和600KB,用 first-fit,best-fit和 worst-fit 算 法 , 能 够 怎 样 按 顺 序 分 配 进 程212KB,417KB,112KB,426KB和426KB?哪个算法充

27、分利用了内存空间?)答:作业 ch9- 第二题(1 ) first-fit,best-fit和 worst-fit 算法分配进程如下:First-fit:212K is put in 500K partition417K is put in 600K partition112K is put in 288K partition (new partition 288K = 500K- 212K)426K must waitBest-fit:212K is put in 300K partition417K is put in 500K partition112K is put in 200K p

28、artition426K is put in 600K partitionWorst-fit:212K is put in 600K partition417K is put in 500K partition112K is put in 388K partition426K must wait(2) Best-fit 算法充分利用了内存空间。第七版 8.12Consider the following segment table:SegmentBaseLength021Q6001230014r-0010031327580415296What are the physical addresse

29、s for the follow ing logical addresses?a. 0,430b. 1,10c. 2,500d. 3,400e. 4,112答:作业ch9-第四题a. 430<600, 219+430 = 649;b. 10<14, 2300+10 = 2310;c. 500>100, illegal;d. 400<580, 1327+400 = 1727;e. 112>96, illegal第九章9.13 一个页面置换算法应使发生页错误的次数最小化。怎样才能通过将使用频率高的页平 均分配到整个内存而不只是竞争少数几个页帧页来达到这种最小化。可以对

30、每个页帧设置 一个计数器来记录与此帧相关的页数。那么当置换一个页时,就可以查找计数器值最小的 页帧An swer:a. 定义一个页面置换算法解决问题:I .计数器初始值0;n.计数器值增加一一每当新的一页与此帧相关联;川.计数器值减少一一每当与此帧相关联的一个页不再需要;w .怎样选择要被置换的页一一找到带有最小计数器值的帧。使用先进先出算法解除其关系b. 14个页错误c. 11个页错误9.15颠簸的原因是什么?系统怎样检测颠簸? 一旦系统检测到颠簸,系统怎样做来消除这个问题?An swer:分配的页数少于进程所需的最小页数时发生颠簸,并迫使它不断地页错误。该系统可通过对比多道程序的程度来估计

31、CPU利用率的程度,以此来检测颠簸。降低多道程序的程度可以消除颠簸。第十章第六版 10.11Con sider the follow ing page reference stri ng:1,2, 3, 4, 2, 1,5, 6, 2, 1,2, 3, 7, 6, 3, 2, 1,2, 3, 6.Howmany page faults would occur for the followingreplacement algorithms,assuming one, two, three, four, five, six, or seven frames? Rememberall frames

32、are initially empty, so your first unique pages will all cost one fault each.LRU replaceme ntFIFO replaceme ntOptimal replaceme ntAnswerNumber framesLRUFIFOOptimal1202020218181531611410148581U7671077777第十二章12.1 Consider a file currently consisting of 100 blocks. Assume that the file control block (a

33、ndthe index block, in the case of indexed allocation) is already in memory. Calculate how many disk I/O operations are required for contiguous, linked, and indexed (single-level) allocati on strategies, if, for one block, the follow ing con diti ons hold. In the con tiguousallocati on case, assume t

34、hat there is no room to grow in the beg inning, but there is room to grow in the end. Assume that the block information to be added is stored in memory.a. The block is added at the beg inning.b. The block is added in the middle.c. The block is added at the end.d. The block is removed from the begi nning.e. The block is removed from the middle.f. The block is removed from the end.ContiguousLinkedIndexeda.20111b101521c.131d.1981(1985200100012.2 Suppose that a disk drive has

温馨提示

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

评论

0/150

提交评论