操作系统概念第六版作业解答1PPT课件

上传人:无*** 文档编号:182251718 上传时间:2023-01-21 格式:PPT 页数:35 大小:132.50KB
收藏 版权申诉 举报 下载
操作系统概念第六版作业解答1PPT课件_第1页
第1页 / 共35页
操作系统概念第六版作业解答1PPT课件_第2页
第2页 / 共35页
操作系统概念第六版作业解答1PPT课件_第3页
第3页 / 共35页
资源描述:

《操作系统概念第六版作业解答1PPT课件》由会员分享,可在线阅读,更多相关《操作系统概念第六版作业解答1PPT课件(35页珍藏版)》请在装配图网上搜索。

1、2021/7/231Chapter 1n1.1 What are the three main purposes of an operating system?n环境提供者,为计算机用户提供一个环境,使得能够在计算机硬件上方便、高效的执行程序n资源分配者,为解决问题按需分配计算机的资源,资源分配需尽可能公平、高效n控制程序n监控用户程序的执行,防止出错和对计算机的不正当使用n管理I/O设备的运行和控制2021/7/2321-cont.n1.3 What is the main advantage of multiprogramming?n高效地使用CPU,通过重叠来自不同用户对CPU和I/O设

2、备的需求n增加CPU的利用,设法让CPU执行有意义的指令2021/7/2331-cont.n1.5 In a multiprogramming and time-sharing environment,several users share the system simultaneously.This situation can result in various security problems.na.What are two such problems?nb.Can we ensure the same degree of security in a time-shared machin

3、e as we have in a dedicated machine?Explain your answer.n用户之间互相偷数据、代码n对系统资源使用的记账信息2021/7/2341-cont.n1.6 Define the essential properties of the following types of operating systems:na.Batchn相似需求的Job分批、成组的在计算机上执行,Job由操作员或自动Job程序装置装载;n可以通过采用 buffering,off-line operation,spooling,multiprogramming 等技术使CP

4、U 和 I/O不停忙来提高性能n批处理适合于需要极少用户交互的Job。nb.Interactiven由许多短交易组成,下一次交易的结果可能不可预知n需要响应时间短2021/7/2351-cont.n1.6 Define the essential properties of the following types of operating systems:nc.Time sharingn使用CPU调度和多道程序提供对系统的经济交互式使用,CPU快速地在用户之间切换n一般从终端读取控制,输出立即打印到屏幕nd.Real timen在专门系统中使用,从传感器读取信息,必须在规定时间内作出响应以确保

5、正确的执行2021/7/2361-cont.n1.6 Define the essential properties of the following types of operating systems:ne.Networkn在通用OS上添加n联网、通信功能n远程过程调用n文件共享nf.Distributedn具有联网、通信功能n提供远程过程调用n提供多处理机的统一调度调度n统一的存储管理n分布式文件系统2021/7/2371-cont.n1.9 Describe the differences between symmetric and asymmetric multiprocessing

6、.What are three advantages and one disadvantage of multiprocessor systems?nSymmetric multiprocessing中所有处理器同等对待,I/O可以在任意CPU上处理。nAsymmetric multiprocessing具有一个主CPU和多个从CPU,主CPU将任务分派到从CPU,I/O通常只能由主CPU处理。n多处理机系统的优点n比多个计算机系统可能更省钱(同样CPU个数)n执行程序更快n可靠性更高n缺点:软硬件更复杂2021/7/238Chapter 2n2.2 How does the distinct

7、ion between monitor mode and user mode function as a rudimentary form of protection(security)system?n通过建立一组只能在monitor mode才能执行的特权指令集,OS能够确保总是能控制整个系统。2021/7/2392-cont.n2.3 What are the differences between a trap and an interrupt?What is the use of each function?nAn interrupt是硬件产生的系统内的流的改变nA trap是软件产生

8、的“中断”。ninterrupt可以被I/O用来产生完成的信号,从而避免CPU对设备的轮询 nA trap可以用来调用OS的例程或者捕获算术错误 2021/7/23102-cont.n2.5 Which of the following instructions should be privileged?na.Set value of timer.nb.Read the clock.nc.Clear memory.nd.Turn off interrupts.ne.Switch from user to monitor mode.na.Set value of timer.nc.Clear m

9、emory.nd.Turn off interrupts.ne.Switch from user to monitor mode.2021/7/23112-cont.n2.8 Protecting the operating system is crucial to ensuring that the computer system operates correctly.Provision of this protection is the reason behind dual-mode operation,memory protection,and the timer.To allow ma

10、ximum flexibility,however,we would also like to place minimal constraints on the user.The following is a list of operations that are normally protected.What is the minimal set of instructions that must be protected?na.Change to user mode.nb.Change to monitor mode.nc.Read from monitor memory.nd.Write

11、 into monitor memory.ne.Fetch an instruction from monitor memory.nf.Turn on timer interrupt.ng.Turn off timer interrupt.nb.Change to monitor mode.nc.Read from monitor memory.nd.Write into monitor memory.ng.Turn off timer interrupt.2021/7/2312Chapter 3n3.1 What are the five major activities of an ope

12、rating system in regard to process management?n用户和系统进程地创建和删除n 进程的挂起和恢复n 提供进程同步的机制n 提供进程通信的机制n 提供死锁处理的机制2021/7/23133-cont.n3.2 What are the three major activities of an operating system in regard to memory management?n跟踪内存使用情况(哪一部分被使用、谁使用)n当内存空间可用的时候,确定将哪些进程调入内存(job调度)n按需要分配和回收内存2021/7/23143-cont.n3.

13、3 What are the three major activities of an operating system in regard to secondary-storage management?n剩余空间的管理n存储分配n磁盘调度2021/7/23153-cont.n3.4 What are the five major activities of an operating system in regard to file management?n文件创建和删除n目录创建和删除n目录和文件操作原语的支持n文件到二级存储的映射n将文件备份到非易失存储设备2021/7/23163-co

14、nt.n3.5 What is the purpose of the command interpreter?Why is it usually separate from the kernel?n读取命令(从用户或者命令文件)并执行(转化成系统调用)n可能会经常改变2021/7/23173-cont.n3.7 What is the purpose of system calls?n让用户级进程可以请求操作系统所提供的服务2021/7/23183-cont.n3.10 What is the purpose of system programs?n为程序开发和运行提供了方便的环境n给用户提供

15、基本的公共功能函数,为用户在不用自己写代码的情况下解决公用问题n试着安装虚拟机试着安装虚拟机VMWARE,然后在这台虚拟机上安装,然后在这台虚拟机上安装一个操作系统一个操作系统n阅读阅读Linux源码,给出某一个源码,给出某一个system call的源码并分的源码并分析,分析析,分析init/main.c给出流程图给出流程图2021/7/2319Chapter 4n4.2 Describe the differences among short-term,medium-term,and long-term scheduling.nShort-term,CPU调度nLong-term,job调

16、度nMedium-term,分时系统中的中间调度级2021/7/23204-cont.n4.4 Describe the actions a kernel takes to context switch between processes.n保存正在运行的进程的状态、恢复欲调度到CPU进程的状态2021/7/23214-cont.n4.5 What are the benefits and detriments of each of the following?Consider both the systems and the programmers levels.na.Symmetric a

17、nd asymmetric communicationnb.Automatic and explicit bufferingnc.Send by copy and send by referencend.Fixed-sized and variable-sized messages2021/7/23224-cont.n4.6 The correct producerconsumer algorithm in Section 4.4 allows only n-1 buffers to be full at any one time.Modify the algorithm to allow a

18、ll buffers to be utilized fully.2021/7/23234-cont.n4.7 Consider the interprocess-communication scheme where mailboxes are used.na.Suppose a process P wants to wait for two messages,one from mailbox A and one from mailbox B.What sequence of send and receive should it execute?nb.What sequence of send

19、and receive should P execute if P wants to wait for one message either from mailbox A or from mailbox B(or from both)?nc.A receive operation makes a process wait until the mailbox is nonempty.Either devise a scheme that allows a process to wait until a mailbox is empty,or explain why such a scheme c

20、annot exist.nanreceive(A,m1)receive(B,m2)send(c,m3)nreceive(B,m1)receive(A,m2)send(c,m3)nbnreceive(A,m1)receive(B,m2)send(c,m3)nreceive(B,m1)receive(A,m2)send(c,m3)nreceive(A,m1)send(c,m3)receive(B,m2)nreceive(B,m1)send(c,m3)receive(A,m2)2021/7/23244-cont.n阅读分析阅读分析Linux终止进程的源码终止进程的源码n编程,实现一个简单网络聊天程序

21、,用到编程,实现一个简单网络聊天程序,用到socket和和fork()(接受和发送在(接受和发送在fork出的进程中)出的进程中)2021/7/2325Chapter 5n5.1 Provide two programming examples of multithreading giving improved performance over a single-threaded solution.n可以并发的多任务nWeb浏览器,数据可并行处理n5.2 Provide two programming examples of multithreading that would not impr

22、ove performance over a single-threaded solution.n不可以并发的单任务n用多个线程读一个文件n后续的结果必须依赖于前面的2021/7/23265 cont.n5.3 What are two differences between user-level threads and kernel-level threads?Under what circumstances is one type better than the other?n内核可知与不可知n调度者不同n与进程的关系n运行效率、内核复杂度、用户可控程度n5.6 What resource

23、s are used when a thread is created?How do they differ from those used when a process is created?2021/7/23275 cont.n5.6 What resources are used when a thread is created?How do they differ from those used when a process is created?nTCB,寄存器组,栈,调度信息nPCB,所有与进程执行和调度相关的资源与信息,内存,打开的文件,环境变量2021/7/23285-cont

24、.n5.9 Write a multithreaded Pthread or Java program that outputs prime numbers.This program should work as follows:The user will run the program and will enter a number on the command line.The program will then create a separate thread that outputs all the prime numbers less than or equal to the num

25、ber that the user entered.n编程,实现一个简单网络聊天程序,用到编程,实现一个简单网络聊天程序,用到socket和和pthread(接受和发送在(接受和发送在pthread创建的线程中)创建的线程中)2021/7/2329Chapter 6n6.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 d

26、ifferent schedules are there?Give a formula in terms of n.nN个进程的排列问题nPnn=n!n6.2 Define the difference between preemptive and nonpreemptive scheduling.State why strict nonpreemptive scheduling is unlikely to be used in a computer center.n对CPU控制权的主动还是被动放弃n不可能采用纯非剥夺机制:考虑到多道程序、分时共享,公平和轻重缓急2021/7/23306-c

27、ont.n6.3 Consider the following set of processes,with the length of the CPU-burst time given in milliseconds:nThe processes are assumed to have arrived in the order P1,P2,P3,P4,P5,all at time 0.na.Draw four Gantt charts illustrating the execution of these processes using FCFS,SJF,a nonpreemptive pri

28、ority(a smaller priority number implies a higher priority),and RR(quantum=1)scheduling.nb.What is the turnaround time of each process for each of the scheduling algorithms in part a?nc.What is the waiting time of each process for each of the scheduling algorithms in part a?nd.Which of the schedules

29、in part a results in the minimal average waiting time(over all processes)?2021/7/23316-cont.n6.3 na.n b.n c.nd.SJF2021/7/23326-cont.n6.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 non

30、preemptive scheduling and base all decisions on the information you have at the time the decision must be made.na.What is the average turnaround time for these processes with the FCFS scheduling algorithm?(8-0)+(12-0.4)+(13-1.0)/3=10.53 nb.What is the average turnaround time for these processes with

31、 the SJF scheduling algorithm?(8-0)+(13-0.4)+(9-1.0)/3=9.53nc.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

32、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.(14-0)+(6-0.4)+(2-1.0)/3=6.872021/7/23336-cont.n6.7 Consider the followin

33、g preemptive priority-scheduling algorithm based on dynamically changing priorities.Larger priority numbers imply higher priority.When a process is waiting for the CPU(in the ready queue but not running),its priority changes at a rate A;when it is running,its priority changes at a rate B.All process

34、es are given a priority of 0 when they enter the ready queue.The parameters A and B can be set to give many different scheduling algorithms.na.What is the algorithm that results from BA0?nb.What is the algorithm that results from AB0?nFCFSnLIFO2021/7/23346-cont.n6.8 Many CPU scheduling algorithms ar

35、e parameterized.For example,the RR algorithm requires a parameter to indicate the time slice.Multilevel feedback queues require parameters to define the number of queues,the scheduling algorithms for each queue,the criteria used to move processes between queues,and so on.These algorithms are thus re

36、ally sets of algorithms(for example,the set of RR algorithms for all time slices,and so on).One set of algorithms may include another(for example,the FCFS algorithm is the RR algorithm with an infinite time quantum).What(if any)relation holds between the following pairs of sets of algorithms?na.Prio

37、rity and SJF(最短job优先级最高)nb.Multilevel feedback queues and FCFS(MLFQ的最低级是FCFS)nc.Priority and FCFS(FCFS给存在时间最长的优先级最高)nd.RR and SJF(none)2021/7/23356-cont.n6.9 Suppose that a scheduling algorithm(at the level of short-term CPU scheduling)favors those processes that have used the least processor time in the recent past.Why will this algorithm favor I/O-bound programs and yet not permanently starve CPU-bound programs?n阅读分析阅读分析Linux sched.c

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

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!