操作系统课后重点习题整理

上传人:mg****85 文档编号:34207060 上传时间:2018-02-21 格式:DOC 页数:10 大小:197.50KB
返回 下载 相关 举报
操作系统课后重点习题整理_第1页
第1页 / 共10页
操作系统课后重点习题整理_第2页
第2页 / 共10页
操作系统课后重点习题整理_第3页
第3页 / 共10页
操作系统课后重点习题整理_第4页
第4页 / 共10页
操作系统课后重点习题整理_第5页
第5页 / 共10页
点击查看更多>>
资源描述

《操作系统课后重点习题整理》由会员分享,可在线阅读,更多相关《操作系统课后重点习题整理(10页珍藏版)》请在金锄头文库上搜索。

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程序装置装载;可以通过采用 buffering,

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

3、uted具有联网、通信功能提供远程过程调用提供多处理机的统一调度调度统一的存储管理分布式文件系统第二章第六版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.3 讨论向操作系统传递参数的三个主

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

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

6、he CPU-burst time given in milliseconds:(考虑下列进程集,进程占用的 CPU 区间长度以毫秒来计算:)The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time 0.(假设在时刻 0 以进程 P1,P 2,P 3,P 4,P 5的顺序到达。 )a. Draw four Gantt charts illustrating the execution of these processes using FCFS, SJF, a nonpreempt

7、ive 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 algorithms in part a?(在 a 里每个进程在每种调度算法下的周转时间是多少?)c. Wha

8、t is the waiting time of each process for each of the scheduling 进程 区间时间 优先级P1 10 3P2 1 1P3 2 3P4 1 4P5 5 2algorithms in part a?(在 a 里每个进程在每种调度算法下的等待时间是多少?)d. Which of the schedules in part a results in the minimal average waiting time (over all processes)?(在 a 里哪一种调度算法的平均等待时间对所有进程而言最小?)答:作业 ch6-第三题

9、第六章第六版6.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.a. What is th

10、e average turnaround time for these processes with the FCFS scheduling algorithm?b. What is the average turnaround time for these processes with the SJF scheduling algorithm?c. The SJF algorithm is supposed to improve performance, but notice that we chose to run process P1 at time 0 because we did n

11、ot 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

12、 could be known as future-knowledge scheduling.答: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 consists of a waiting room with n chairs and the barber room containing the barber chair.

13、If there are no customers to be served, the barber goes to sleep. If a customer enters the barbershop and all chairs are occupied, then the customer leaves the shop. If the barber is busy but chairs are available, then the customer sits in one of the free chairs. If the barber is asleep, the custome

14、r wakes up the barber. Write a program to coordinate the barber and the customers.答:作业 ch7-第四题理发师和顾客同步,理发师必须由顾客唤醒,理发师给一个顾客理发完,要让理发完的顾客退出,让等待顾客进入,顾客互斥的占用 n 个位置/共享变量semaphore Scuthair, Snumchair;/ Scuthair 制约理发师, Snumchair 制约顾客Scuthair=0; Snumchair=0;barber:do wait(Scuthair);/检查是否有顾客,无就睡眠给某个顾客理发signal

15、(Snumchair);/让理发完的顾客退出,让等待的一个顾客进入 while (1);Customer i:wait(Snumchair);/申请占用椅子signal(Scuthair);/给理发师发一个信号坐在椅子上等着理发/共享变量semaphore Scuthair, Mutexchair;/ Scuthair 给理发师, Mutexchair 制约顾客对椅子的互斥占领int number = 0;/顾客的共享变量,记录已经有的顾客数Scuthair=0; Mutexchair =1;Customer i:wait(Mutexchair);/申请对共享变量 number 的操作(申请占用椅子)if(number = = n-1)signal(Mutexchair); exit;number = number +1;signal(Scuthair);/给理发师发一个信号signal(Mutexchair);等待理发理发完毕wait(Mutexchair);/申请对共享变量 number 的操作number = number -1;signal(Mutexchair);离开理发店barber:do wait(Scuthair);/检查是否有顾客,无,就睡眠给某个顾客理发 while (1);第七章第七版 7.5 In a

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号