操作系统习题解析分析解析
操作系统-第4章习题解析
操作系统-第4章习题解析第4章习题解析1.为什么要配置层次式存储器?答:这是因为: a.设置多个存储器可以使存储器两端的硬件能并⾏⼯作。
b.采⽤多级存储系统,特别是Cache技术,这是⼀种减轻存储器带宽对系统性能影响的最佳结构⽅案。
c.在微处理机内部设置各种缓冲存储器,以减轻对存储器存取的压⼒。
增加CPU中寄存器的数量,也可⼤⼤缓解对存储器的压⼒。
2.可采⽤哪⼏种⽅式将程序装⼊内存?它们分别适⽤于何种场合?答:将程序装⼊内存可采⽤的⽅式有:绝对装⼊⽅式、重定位装⼊⽅式、动态运⾏时装⼊⽅式;绝对装⼊⽅式适⽤于单道程序环境中,重定位装⼊⽅式和动态运⾏时装⼊⽅式适⽤于多道程序环境中。
3.何为静态链接?静态链接时需要解决两个什么问题?答:静态链接是指在程序运⾏之前,先将各⾃⽬标模块及它们所需的库函数,链接成⼀个完整的装⼊模块,以后不再拆开的链接⽅式。
将⼏个⽬标链接装配成⼀个装⼊模块时,需解决以下两个问题: 将相对地址进⾏修改。
即将除第⼀个模块外的相对地址修改成装⼊模块中的相应的相对地址。
变换外部调⽤符号。
即将每个模块中所⽤的外部调⽤符号,都变换为相对地址。
4.何谓装⼊时动态链接?装⼊时动态链接⽅式有何优点?答:装⼊时动态链接是指将⽤户源程序编译后所得到的⼀组⽬标模块,在装⼊内存时,采⽤边装⼊边链接的⼀种链接⽅式,即在装⼊⼀个⽬标模块时,若发⽣⼀个外部模块调⽤事件,将引起装⼊程序去找相应的外部⽬标模块,把它装⼊内存中,并修改⽬标模块中的相对地址。
装⼊时动态链接⽅式有以下优点: 1)便于修改和更新 2)便于实现对⽬标模块的共享5.何谓运⾏时动态链接?运⾏时动态链接⽅式有何优点?答:运⾏时动态链接是将对某些模块的链接推迟到程序执⾏时才进⾏链接,也就是,在执⾏过程中,当发现⼀个被调⽤模块尚未装⼊内存时,⽴即由0S去找到该模块并将之装⼊内存,把它链接到调⽤者模块上。
优点:凡是在执⾏过程中未被⽤过的⽬标模块,都不会被调⼊内存和被链接到装⼊模块上,这样不仅能加快程序的装⼊过程,⽽且可节省⼤量的内存空间。
操作系统练习题_及答案解析
操作系统练习题第一章引言(一单项选择题1 操作系统是计算机系统的一种( 。
A.应用软件B. 系统软件c. 通用软件D.工具软件2.操作系统目的是提供一个供其他程序执行的良好环境,因此它必须使计算机( A.使用方便B. 高效工作C.合理使用资源D.使用方便并高效工作3.允许多个用户以交互方式使用计算机的操作系统是( 。
A.分时操作系统B. 批处理单道系统C.实时操作系统D.批处理多道系统4.下列系统中( 是实时系统。
A.计算机激光照排系统B. 办公自动化系统C.化学反应堆控制系统D.计算机辅助设计系统5.操作系统是一种系统软件,它( 。
A.控制程序的执行B. 管理计算机系统的资源C.方便用户使用计算机D.管理计算机系统的资源和控制程序的执行6.计算机系统把进行( 和控制程序执行的功能集中组成一种软件,称为操作系统A.CPU 管理B.作业管理C.资源管理D.设备管理7.批处理操作系统提高了计算机系统的工作效率,但( 。
A.不能自动选择作业执行B. 无法协调资源分配c.不能缩短作业执行时间D 在作业执行时用户不能直接干预8.分时操作系统适用于( 。
A.控制生产流水线B.调试运行程序c.大量的数据处理D.多个计算机资源共享9.在混合型操作系统中,“前台”作业往往是指( 。
A.由批量单道系统控制的作业B.由批量多道系统控制的作业c.由分时系统控制的作业D.由实时系统控制的作业10.在批处理兼分时的系统中,对( 应该及时响应,使用户满意。
A.批量作业B.前台作业c.后台作业D.网络通信11.实时操作系统对可靠性和安全性要求极高,它( 。
A.十分注重系统资源的利用率B.不强调响应速度c.不强求系统资源的利用率D.不必向用户反馈信息12.分布式操作系统与网络操作系统本质上的不同之处在于( 。
A.实现各台计算机之间的通信B.共享网络个的资源c.满足较大规模的应用D.系统中若干台计算机相互协作完成同一任务13.SPOOL技术用于( 。
操作系统习题解析
已知一个求值公式(A2+3B)/(B+5A),若A,B已赋值,试画 出该公式求值过程的前趋图,并用信号量解决公式的求解过程。 开始 S1:x1=A*A S2:x2=3*B S3:x3=5*A S1 S4:x4=x1+x2 S5:x5=B+x3 S4 S6:x6=x4/x5 结束 S5 S2 S3
A:1
B:2
C:4 D:2
7.下面8个系统中,必须是实时操作系统的有( ) A计算机辅助设计系统;B 航空定票系统;C 过程控制系统;D 机器翻译系统;E 办公自动化 系统;F 计算机激光照排系统;G情报检索系统;H导弹的制导系统
ABCGH
二、 简答题 在操作系统中实现虚拟的关键技术是什么?并加以说明。
操作系统中所谓的”虚拟“,是指通过某种技术把一个物理实体变为若干个逻辑上 的对应物,相应的用于实现虚拟的技术称为虚拟技术。在操作系统中利用了多种虚拟技 术分别用来实现虚拟处理机、虚拟内存、虚拟外设和虚拟信道等。虚拟的实现主要是通 过分时技术,例如,多道程序系统中,通过分时技术来实现虚拟处理机;将一台物理处 理机虚拟为多台逻辑上的处理机,是靠多道程序分时地使用同一台物理处理机来实现的。 微观上,该处理机在每一时刻只运行一道程序,它们分时地运行;然而在宏观上,系统 中确有几道程序在同时运行,从而给用户的感觉是系统中同时同时有多台处理机在为其 中的每一道程序服务,显然用户所感觉到的处理机并不实际存在。
A:4 B:5
5.采用(A)结构时,将OS分成用于实现OS最基本功能的内核和提供各种服务的服 务器两个部分。通常,下列模块中必须包含在操作系统内核中的是(B)模块。 A:(1)整体式;(2)模块化;(3)层次式;(4)微内核。 B:(1)内存分配;(2)中断处理;(3)文件处理;(4)命令处理。 A:4 B:2
操作系统第九版部分课后作业习题答案分析解析
CHAPTER 9 Virtual Memory Practice Exercises9.1 Under what circumstances do page faults occur? Describe the actions taken by the operating system when a page fault occurs.Answer:A page fault occurs when an access to a page that has not beenbrought into main memory takes place. The operating system veri?esthe memory access, aborting the program if it is invalid. If it is valid, a free frame is located and I/O is requested to read the needed page into the free frame. Upon completion of I/O, the process table and page table are updated and the instruction is restarted.9.2 Assume that you have a page-reference string for a process with m frames (initially all empty). The page-reference string has length p;n distinct page numbers occur in it. Answer these questions for anypage-replacement algorithms:a. What is a lower bound on the number of page faults?b. What is an upper bound on the number of page faults?Answer:a. nb. p9.3 Consider the page table shown in Figure 9.30 for a system with 12-bit virtual and physical addresses and with 256-byte pages. The list of freepage frames is D, E, F (that is, D is at the head of the list, E is second,and F is last).Convert the following virtual addresses to their equivalent physicaladdresses in hexadecimal. All numbers are given in hexadecimal. (Adash for a page frame indicates that the page is not in memory.)? 9EF? 1112930 Chapter 9 Virtual Memory? 700? 0FFAnswer:? 9E F - 0E F? 111 - 211? 700 - D00? 0F F - EFF9.4 Consider the following page-replacement algorithms. Rank thesealgorithms on a ?ve-point scale from “bad” to “perfect” according to the page-fault rate. Separate those algorithms that suffer from Belady’sanomaly from those that do not.a. LRU replacementb. FIFO replacementc. Optimal replacementd. Second-chance replacementAnswer:Rank Algorithm Suffer from Belady’s anomaly1 Optimal no2 LRU no3 Second-chance yes4 FIFO yes9.5 Discuss the hardware support required to support demand paging. Answer:For every memory-access operation, the page table needs to be consulted to check whether the corresponding page is resident or not and whetherthe program has read or write privileges for accessing the page. These checks have to be performed in hardware. A TLB could serve as a cache and improve the performance of the lookup operation.9.6 An operating system supports a paged virtual memory, using a central processor with a cycle time of 1 microsecond. It costs an additional 1 microsecond to access a page other than the current one. Pages have 1000 words, and the paging device is a drum that rotates at 3000 revolutionsper minute and transfers 1 million words per second. The following statistical measurements were obtained from the system:page other than the? 1 percent of all instructions executed accessed acurrent page.?Of the instructions that accessed another page, 80 percent accesseda page already in memory.Practice Exercises 31?When a new page was required, the replaced page was modi?ed 50 percent of the time.Calculate the effective instruction time on this system, assuming that the system is running one process only and that the processor is idle during drum transfers.Answer:(2 sec)(1sec + 0.008 ×effective access time = 0.99 ×(10,000 sec + 1,000 sec)+ 0.002 ×(10,000 sec + 1,000 sec)+ 0.001 ×9.7 Consider the two-dimensional array A:int A[][] = new int[100][100];where A[0][0] is at location 200 in a paged memory system with pages of size 200. A small process that manipulates the matrix resides in page 0 (locations 0 to 199). Thus, every instruction fetch will be from page 0. For three page frames, how many page faults are generated bythe following array-initialization loops, using LRU replacement andassuming that page frame 1 contains the process and the other two are initially empty?a. for (int j = 0; j < 100; j++)for (int i = 0; i < 100; i++)A[i][j] = 0;b. for (int i = 0; i < 100; i++)for (int j = 0; j < 100; j++)A[i][j] = 0;Answer:a. 5,000b. 509.8 Consider the following page reference string:1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 2, 3, 7, 6, 3, 2, 1, 2, 3, 6.How many page faults would occur for the following replacement algorithms, assuming one, two, three, four, ?ve, six, or seven frames? Remember all frames are initially empty, so your ?rst unique pages will all cost one fault each.?LRU replacement? FIFO replacement?Optimal replacement32 Chapter 9 Virtual MemoryAnswer:Number of frames LRU FIFO Optimal1 20 20 202 18 18 153 15 16 114 10 14 85 8 10 76 7 10 77 77 79.9 Suppose that you want to use a paging algorithm that requires a referencebit (such as second-chance replacement or working-set model), butthe hardware does not provide one. Sketch how you could simulate a reference bit even if one were not provided by the hardware, or explain why it is not possible to do so. If it is possible, calculate what the cost would be.Answer:You can use the valid/invalid bit supported in hardware to simulate the reference bit. Initially set the bit to invalid. On ?rst reference a trap to the operating system is generated. The operating system will set a software bit to 1 and reset the valid/invalid bit to valid.9.10 You have devised a new page-replacement algorithm that you thinkmaybe optimal. In some contorte d test cases, Belady’s anomaly occurs. Is thenew algorithm optimal? Explain your answer.Answer:No. An optimal algorithm will not suffer from Belady’s anomaly beca an optimal algorithm replaces the page that will not—by de?nition—be used for the longest time. Belady’s anomaly occurs when a pagereplacement a lgorithm evicts a page that will be needed in theimmediatefuture. An optimal algorithm would not have selected such a page.9.11 Segmentation is similar to paging but usesnevariable-sized“pages.”De?two segment-replacement algorithms based on FIFO and LRU pagereplacement s chemes. Remember that since segments are not thesamesize, the segment that is chosen to be replaced may not be big enoughto leave enough consecutive locations for the needed segment. Considerstrategies for systems where segments cannot be relocated, and thosefor systems where they can.Answer:a. FIFO. Find the ?rst segment large enough to accommodate theincoming segment. If relocation is not possible and no one segmentis large enough, select a combination of segments whose memoriesare contiguous, which are “closest to the ?rst of the list” and which can accommodate the new segment. If relocation is possible,rearrange the memory so that the ?rstNsegments large enough forthe incoming segment are contiguous in memory. Add any leftoverspace to the free-space list in both cases.Practice Exercises 33b. LRU. Select the segment that has not been used for the longestperiod of time and that is large enough, adding any leftover spaceto the free space list. If no one segment is large enough, selecta combination of the “oldest” segments that are contiguous inmemory (if relocation is not available) and that are large enough.If relocation is available, rearrange the oldest N segments to becontiguous in memory and replace those with the new segment.9.12 Consider a demand-paged computer system where the degree of multiprogramming is currently ?xed at four. The system was recentlymeasured to determine utilization of CPU and the paging disk. The resultsare one of the following alternatives. For each case, what is happening?Can the degree of multiprogramming be increased to increase the CPU utilization? Is the paging helping?a. CPU utilization 13 percent; disk utilization 97 percentb. CPU utilization 87 percent; disk utilization 3 percentc. CPU utilization 13 percent; disk utilization 3 percentAnswer:a. Thrashing is occurring.b. CPU utilization is suf?ciently high to leave things alone, andincrease degree of multiprogramming.c. Increase the degree of multiprogramming.9.13 We have an operating system for a machine that uses base and limit registers, but we have modi?ed the ma chine to provide a page table.Can the page tables be set up to simulate base and limit registers? How can they be, or why can they not be?Answer:The page table can be set up to simulate base and limit registers provided that the memory is allocated in ?xed-size segments. In this way, the base of a segment can be entered into the page table and the valid/invalid bit used to indicate that portion of the segment as resident in the memory. There will be some problem with internal fragmentation.9.27.Consider a demand-paging system with the following time-measured utilizations:CPU utilization 20%Paging disk 97.7%Other I/O devices 5%Which (if any) of the following will (probably) improve CPU utilization? Explain your answer.a. Install a faster CPU.b. Install a bigger paging disk.c. Increase the degree of multiprogramming.d. Decrease the degree of multiprogramming.e. Install more main memory.f. Install a faster hard disk or multiple controllers with multiple hard disks.g. Add prepaging to the page fetch algorithms.h. Increase the page size.Answer: The system obviously is spending most of its time paging, indicating over-allocationof memory. If the level of multiprogramming is reduced resident processeswould page fault less frequently and the CPU utilization would improve. Another way toimprove performance would be to get more physical memory or a faster paging drum.a. Get a faster CPU—No.b. Get a bigger paging drum—No.c. Increase the degree of multiprogramming—No.d. Decrease the degree of multiprogramming—Yes.e. Install more main memory—Likely to improve CPU utilization as more pages canremain resident and not require paging to or from the disks.f. Install a faster hard disk, or multiple controllers with multiple hard disks—Also animprovement, for as the disk bottleneck is removed by faster response and morethroughput to the disks, the CPU will get more data more quickly.g. Add prepaging to the page fetch algorithms—Again, the CPU will get more datafaster, so it will be more in use. This is only the case if the paging actionis amenableto prefetching (i.e., some of the access is sequential).h. Increase the page size—Increasing the page size will result in fewer page faults ifdata is being accessed sequentially. If data access is more or less random, morepaging action could ensue because f ewer pages c an be kept in memory and moredata is transferred per page fault. So this change is as likely to decrease utilizationas it is to increase it.10.1、Is disk scheduling, other than FCFS scheduling, useful in a single-userenvironment? Explain your answer.Answer: In a single-user environment, the I/O queue usually is empty. Requests g enerally arrive from a single process for one block or for a sequence of consecutive blocks. In these cases, FCFS is an economical method of disk scheduling. But LOOK is nearly as easy to program and will give much better performance when multiple processes are performing concurrent I/O, such as when aWeb browser retrieves data in the background while the operating system is paging and another application is active in the foreground.10.2.Explain why SSTF scheduling tends to favor middle cylindersover theinnermost and outermost cylinders.The center of the disk is the location having the smallest average distance to all other tracks.Thus the disk head tends to move away from the edges of the disk.Here is another way to think of it.The current location of the head divides the cylinders into two groups.If the head is not in the center of the disk and a new request arrives,the new request is more likely to be in the group that includes the center of the disk;thus,the head is more likely to move in that direction.10.11、Suppose that a disk drive has 5000 cylinders, numbered 0 to 4999. The drive is currently serving a request at cylinder 143, and the previous request was at cylinder 125. The queue of pending requests, in FIFO order, is86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130Starting from the current head position, what is the total distance (in cylinders) that the disk arm moves to satisfy all the pending requests, for each of the following disk-scheduling algorithms?a. FCFSb. SSTFc. SCANd. LOOKe. C-SCANAnswer:a. The FCFS schedule is 143, 86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130. The total seek distance is 7081.b. The SSTF schedule is 143, 130, 86, 913, 948, 1022, 1470, 1509, 1750, 1774. The total seek distance is 1745.c. The SCAN schedule is 143, 913, 948, 1022, 1470, 1509, 1750, 1774, 4999, 130, 86. The total seek distance is 9769.d. The LOOK schedule is 143, 913, 948, 1022, 1470, 1509, 1750, 1774, 130, 86. The total seek distance is 3319.e. The C-SCAN schedule is 143, 913, 948, 1022, 1470, 1509, 1750, 1774, 4999, 86, 130. The total seek distance is 9813.f. (Bonus.) The C-LOOK schedule is 143, 913, 948, 1022, 1470, 1509, 1750, 1774, 86, 130. The total seek distance is 3363.12CHAPTERFile-SystemImplementationPractice Exercises12.1 Consider a ?le currently consisting of 100 blocks. Assume that the?lecontrol block (and the 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) allocation strategies, if, for one block, the following conditions hold. In the contiguous-allocation case, assume that there is no room to grow atthe beginning but there is room to grow at the end. Also assume thatthe block information to be added is stored in memory.a. The block is added at the beginning.b. The block is added in the middle.c. The block is added at the end.d. The block is removed from the beginning.e. The block is removed from the middle.f. The block is removed from the end.Answer:The results are:Contiguous Linked Indexeda. 201 1 1b. 101 52 1c. 1 3 1d. 198 1 0e. 98 52 0f. 0 100 012.2 What problems could occur if a system allowed a ?le system to be mounted simultaneously at more than one location?Answer:4344 Chapter 12 File-System ImplementationThere would be multiple paths to the same ?le, which could confuse users or encourage mistakes (deleting a ?le with one path deletes the?le in all the other paths).12.3 Why must the bit map for ?le allocation be kept on mass storage, ratherthan in main memory?Answer:In case of system crash (memory failure) the free-space list would not be lost as it would be if the bit map had been stored in main memory.12.4 Consider a system that supports the strategies of contiguous, linked, and indexed allocation. What criteria should be used in deciding which strategy is best utilized for a particular ?le?Answer:?Contiguous—if ?le is usually accessed sequentially, if ?le isrelatively small.?Linked—if ?le is large and usually accessed sequentially.? Indexed—if ?le is large and usually accessed randomly.12.5 One problem with contiguous allocation is that the user must preallocate enough space for each ?le. If the ?le grows to be larger than thespace allocated for it, special actions must be taken. One solution to this problem is to de?ne a ?le structure consisting of an initial contiguousarea (of a speci?ed size). If this area is ?lled, the operating system automatically de?nes an over?ow area that is linked to the initial contiguous area. If the over?ow area is ?lled, another over?ow areais allocated. Compare this implementation of a ?le with the standard contiguous and linked implementations.Answer:This method requires more overhead then the standard contiguousallocation. It requires less overheadthan the standard linked allocation.12.6 How do caches help improve performance? Why do systems not use more or larger caches if they are so useful?Answer:Caches allow components of differing speeds to communicate moreef?ciently by storing data from the slower device, temporarily, ina faster device (the cache). Caches are, almost by de?nition, moreexpensive than the device they are caching for, so increasing the numberor size of caches would increase system cost.12.7 Why is it advantageous for the user for an operating system to dynamically allocate its internal tables? What are the penalties to the operating system for doing so?Answer:tablesDynamic tables allow more ?exibility in system use growth —are never exceeded, avoiding arti?cial use limits. Unfortunately, kernel structures and code are more complicated, so there is more potentialfor bugs. The use of one resource can take away more system resources (by growing to accommodate the requests) than with static tables.Practice Exercises 4512.8 Explain how the VFS layer allows an operating system to support multiple types of ?le systems easily.Answer:VFS introduces a layer of indirection in the ?le system implementation. In many ways, it is similar to object-oriented programming techniques. System calls can be made generically (independent of ?le system type). Each ?le system type provides its function calls and data structuresto the VFS layer. A system call is translated into the proper speci?c functions for the target ?le system at the VFS layer. The calling program has no ?le-system-speci?c code, and the upper levels of the system call structures likewise are ?le system-independent. The translation at the VFS layer turns these generic calls into ?le-system-speci?c operations.。
2.2 重点与难点习题解析_大学计算机基础实践教程(第2版)_[共10页]
第2章操作系统2.1 重点与难点1.操作系统的定义2.操作系统的功能3.操作系统的发展和分类4.DOS磁盘操作系统的组成5.文件的定义及特征6.文件目录和路径7.Windows操作系统的发展8.Windows操作系统的特点9.Windows操作系统的基本操作2.2 重点与难点习题解析[例题2-1]是用户与计算机之间的接口。
[解析]操作系统是系统软件中最重要的部分。
它为用户提供一个良好环境,是用户与计算机之间的接口。
用户通过操作系统可以最大限度地利用计算机的功能。
同时操作系统对计算机的运行提供有效的管理,合理地调配计算机的软、硬件资源,使计算机各部分协调有效地工作。
[正确答案]操作系统[例题2-2]分时系统是一种操作系统。
[解析]分时操作系统允许一台计算机上挂多个终端,CPU按预先分配给多个终端的时间,轮流为多个终端服务,即各终端在各自占有的时间片内占有CPU,分时共享计算机系统的资源。
但因计算机运行在高速状态,故用户感受不到是处于分时状态,如同自己独占这台计算机。
[正确答案]多用户[例题2-3] DOS操作系统是的简称。
24[解析]DOS(Disk Operating System)是磁盘操作系统的英文缩写。
DOS是用软盘或者硬盘提供的,曾经是微型计算机上广泛使用的操作系统。
DOS提供了用户与计算机之间的接口,使用户能有效地利用计算机的各种资源。
它的主要功能是进行设备管理和文件管理。
[正确答案]磁盘操作系统[例题2-4] DOS系统采用结构来组织文件和目录。
[解析]为了便于管理,DOS系统采用树形目录结构(又称层次结构)来组织文件和目录。
目录与目录之间的隶属关系像一棵倒置的树,树根在上,树叉在下,位于树根的目录称为根目录,位于树叉的目录称为子目录,子目录还可包含子目录,包含子目录的目录又称之为父目录。
每张磁盘只有一个根目录,子目录的个数及其层次要根据实际的情况来决定。
[正确答案]树形目录[例题2-5]是DOS能独立进行存取的最小单位。
操作系统-第3章习题解析
操作系统-第3章习题解析第三章习题解析1.⾼级调度不低级调度的主要任务是什么?为什么要引⼊中级调度?答:⾼级调度的主要任务是根据某种算法,把外存上处于后备队列中的那些作业调⼊内存。
低级调度是保存处理机的现场信息,按某种算法先取进程,再把处理器分配给进程。
引⼊中级调度的主要⽬的是为了提⾼内存利⽤率和系统吞吐量。
使那些暂时不能运⾏的进程不再占⽤内存资源,将它们调⾄外存等待,把进程状态改为就绪驻外存状态或挂起状态。
2.处理机调度算法的共同⽬标是什么?批处理系统的调度⽬标⼜是什么?答:共同⽬标:资源利⽤率,公平性,平衡性,策略强制执⾏。
批处理系统的调度⽬标:平均周转时间短,系统吞吐量⾼,处理机利⽤率⾼。
3.何谓作业、作业步和作业流?答:作业包含通常的程序和数据,还配有作业说明书。
系统根据该说明书对程序的运⾏进⾏控制。
批处理系统中是以作业为基本单位从外存调⼊内存。
作业步是指每个作业运⾏期间都必须经过若⼲个相对独⽴相互关联的顺序加⼯的步骤。
作业流是指若⼲个作业进⼊系统后依次存放在外存上形成的输⼊作业流;在操作系统的控制下,逐个作业进程处理,于是形成了处理作业流。
4.在什么情况下需要使⽤作业控制块JCB?其中包含了哪些内容?答:每当作业进⼊系统时,系统便为每个作业建⽴⼀个作业控制块JCB,根据作业类型将它插⼊到相应的后备队列中。
JCB包含的内容通常有:1)作业标识 2)⽤户名称 3)⽤户账户 4)作业类型(CPU繁忙型、I/0芳名型、批量型、终端型) 5)作业状态 6)调度信息(优先级、作业已运⾏) 7)资源要求 8)进⼊系统时间 9)、开始处理时间 10)作业完成时间 11)作业退出时间 12)资源使⽤情况等5.在作业调度中应如何确定接纳多少个作业和接纳哪些作业?答:作业调度每次接纳进⼊内存的作业数,取决于多道程序度。
应将哪些作业从外存调⼊内存,取决于采⽤的调度算法。
最简单的是先来服务调度算法,较常⽤的是短作业优先调度算法和基于作业优先级的调度算法。
最新操作系统第九版部分课后作业习题答案分析解析
CHAPTER 9 Virtual Memory Practice Exercises9.1 Under what circumstances do page faults occur? Describe the actions taken by the operating system when a page fault occurs.Answer:A page fault occurs when an access to a page that has not beenbrought into main memory takes place. The operating system verifiesthe memory access, aborting the program if it is invalid. If it is valid, a free frame is located and I/O is requested to read the needed page into the free frame. Upon completion of I/O, the process table and page table are updated and the instruction is restarted.9.2 Assume that you have a page-reference string for a process with m frames (initially all empty). The page-reference string has length p;n distinct page numbers occur in it. Answer these questions for any page-replacement algorithms:a. What is a lower bound on the number of page faults?b. What is an upper bound on the number of page faults?Answer:a. nb. p9.3 Consider the page table shown in Figure 9.30 for a system with 12-bit virtual and physical addresses and with 256-byte pages. The list of freepage frames is D, E, F (that is, D is at the head of the list, E is second, and F is last).Convert the following virtual addresses to their equivalent physical addresses in hexadecimal. All numbers are given in hexadecimal. (A dash for a page frame indicates that the page is not in memory.)• 9EF• 1112930 Chapter 9 Virtual Memory• 700• 0FFAnswer:• 9E F - 0E F• 111 - 211• 700 - D00• 0F F - EFF9.4 Consider the following page-replacement algorithms. Rank these algorithms on a five-point scale from “bad” to “perfect” according to their page-fault rate. Separate those algorithms that suffer from Belady’s anomaly from those that do not.a. LRU replacementb. FIFO replacementc. Optimal replacementd. Second-chance replacementAnswer:Rank Algorithm Suffer from Belady’s anomaly1 Optimal no2 LRU no3 Second-chance yes4 FIFO yes9.5 Discuss the hardware support required to support demand paging. Answer:For every memory-access operation, the page table needs to be consulted to check whether the corresponding page is resident or not and whether the program has read or write privileges for accessing the page. These checks have to be performed in hardware. A TLB could serve as a cache and improve the performance of the lookup operation.9.6 An operating system supports a paged virtual memory, using a central processor with a cycle time of 1 microsecond. It costs an additional 1 microsecond to access a page other than the current one. Pages have 1000 words, and the paging device is a drum that rotates at 3000 revolutions per minute and transfers 1 million words per second. The following statistical measurements were obtained from the system:• 1 percent of all instructions executed accessed a page other than the current page.•Of the instructions that accessed another page, 80 percent accesseda page already in memory.Practice Exercises 31•When a new page was required, the replaced page was modified 50 percent of the time.Calculate the effective instruction time on this system, assuming that the system is running one process only and that the processor is idle during drum transfers.Answer:effective access time = 0.99 × (1 sec + 0.008 × (2 sec)+ 0.002 × (10,000 sec + 1,000 sec)+ 0.001 × (10,000 sec + 1,000 sec)= (0.99 + 0.016 + 22.0 + 11.0) sec= 34.0 sec9.7 Consider the two-dimensional array A:int A[][] = new int[100][100];where A[0][0] is at location 200 in a paged memory system with pages of size 200. A small process that manipulates the matrix resides in page 0 (locations 0 to 199). Thus, every instruction fetch will be from page 0. For three page frames, how many page faults are generated bythe following array-initialization loops, using LRU replacement andassuming that page frame 1 contains the process and the other twoare initially empty?a. for (int j = 0; j < 100; j++)for (int i = 0; i < 100; i++)A[i][j] = 0;b. for (int i = 0; i < 100; i++)for (int j = 0; j < 100; j++)A[i][j] = 0;Answer:a. 5,000b. 509.8 Consider the following page reference string:1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 2, 3, 7, 6, 3, 2, 1, 2, 3, 6.How many page faults would occur for the following replacement algorithms, assuming one, two, three, four, five, six, or seven frames? Remember all frames are initially empty, so your first unique pages will all cost one fault each.•LRU replacement• FIFO replacement•Optimal replacement32 Chapter 9 Virtual MemoryAnswer:Number of frames LRU FIFO Optimal1 20 20 202 18 18 153 15 16 114 10 14 85 8 10 76 7 10 77 77 79.9 Suppose that you want to use a paging algorithm that requires a referencebit (such as second-chance replacement or working-set model), butthe hardware does not provide one. Sketch how you could simulate a reference bit even if one were not provided by the hardware, or explain why it is not possible to do so. If it is possible, calculate what the cost would be.Answer:You can use the valid/invalid bit supported in hardware to simulate the reference bit. Initially set the bit to invalid. O n first reference a trap to the operating system is generated. The operating system will set a software bit to 1 and reset the valid/invalid bit to valid.9.10 You have devised a new page-replacement algorithm that you thinkmaybe optimal. In some contorte d test cases, Belady’s anomaly occurs. Is the new algorithm optimal? Explain your answer.Answer:No. An optimal algorithm will not suffer from Belady’s anomaly because —by definition—an optimal algorithm replaces the page that will notbe used for the long est time. Belady’s anomaly occurs when a pagereplacement algorithm evicts a page that will be needed in the immediatefuture. An optimal algorithm would not have selected such a page.9.11 Segmentation is similar to paging but uses variable-sized“pages.”Definetwo segment-replacement algorithms based on FIFO and LRU pagereplacement schemes. Remember that since segments are not the samesize, the segment that is chosen to be replaced may not be big enoughto leave enough consecutive locations for the needed segment. Consider strategies for systems where segments cannot be relocated, and thosefor systems where they can.Answer:a. FIFO. Find the first segment large enough to accommodate the incoming segment. If relocation is not possible and no one segmentis large enough, select a combination of segments whose memoriesare contiguous, which are “closest to the first of the list” andwhich can accommodate the new segment. If relocation is possible, rearrange the memory so that the firstNsegments large enough forthe incoming segment are contiguous in memory. Add any leftover space to the free-space list in both cases.Practice Exercises 33b. LRU. Select the segment that has not been used for the longestperiod of time and that is large enough, adding any leftover spaceto the free space list. If no one segment is large enough, selecta combination of the “oldest” segments that are contiguous inmemory (if relocation is not available) and that are large enough.If relocation is available, rearrange the oldest N segments to be contiguous in memory and replace those with the new segment.9.12 Consider a demand-paged computer system where the degree of multiprogramming is currently fixed at four. The system was recently measured to determine utilization of CPU and the paging disk. The results are one of the following alternatives. For each case, what is happening? Can the degree of multiprogramming be increased to increase the CPU utilization? Is the paging helping?a. CPU utilization 13 percent; disk utilization 97 percentb. CPU utilization 87 percent; disk utilization 3 percentc. CPU utilization 13 percent; disk utilization 3 percentAnswer:a. Thrashing is occurring.b. CPU utilization is sufficiently high to leave things alone, and increase degree of multiprogramming.c. Increase the degree of multiprogramming.9.13 We have an operating system for a machine that uses base and limit registers, but we have modified the machine to provide a page table.Can the page tables be set up to simulate base and limit registers? How can they be, or why can they not be?Answer:The page table can be set up to simulate base and limit registers provided that the memory is allocated in fixed-size segments. In this way, the base of a segment can be entered into the page table and the valid/invalid bit used to indicate that portion of the segment as resident in the memory. There will be some problem with internal fragmentation.9.27.Consider a demand-paging system with the following time-measured utilizations:CPU utilization 20%Paging disk 97.7%Other I/O devices 5%Which (if any) of the following will (probably) improve CPU utilization? Explain your answer.a. Install a faster CPU.b. Install a bigger paging disk.c. Increase the degree of multiprogramming.d. Decrease the degree of multiprogramming.e. Install more main memory.f. Install a faster hard disk or multiple controllers with multiple hard disks.g. Add prepaging to the page fetch algorithms.h. Increase the page size.Answer: The system obviously is spending most of its time paging, indicating over-allocationof memory. If the level of multiprogramming is reduced resident processeswould page fault less frequently and the CPU utilization would improve. Another way toimprove performance would be to get more physical memory or a faster paging drum.a. Get a faster CPU—No.b. Get a bigger paging drum—No.c. Increase the degree of multiprogramming—No.d. Decrease the degree of multiprogramming—Yes.e. Install more main memory—Likely to improve CPU utilization as more pages canremain resident and not require paging to or from the disks.f. Install a faster hard disk, or multiple controllers with multiple hard disks—Also animprovement, for as the disk bottleneck is removed by faster response and morethroughput to the disks, the CPU will get more data more quickly.g. Add prepaging to the page fetch algorithms—Again, the CPU will get more datafaster, so it will be more in use. This is only the case if the paging action is amenableto prefetching (i.e., some of the access is sequential).h. Increase the page size—Increasing the page size will result in fewer page faults ifdata is being accessed sequentially. If data access is more or less random, morepaging action could ensue because fewer pages can be kept in memory and moredata is transferred per page fault. So this change is as likely to decrease utilizationas it is to increase it.10.1、Is disk scheduling, other than FCFS scheduling, useful in asingle-userenvironment? Explain your answer.Answer: In a single-user environment, the I/O queue usually is empty. Requests generally arrive from a single process for one block or for a sequence of consecutive blocks. In these cases, FCFS is an economical method of disk scheduling. But LOOK is nearly as easy to program and will give much better performance when multiple processes are performing concurrent I/O, such as when aWeb browser retrieves data in the background while the operating system is paging and another application is active in the foreground.10.2.Explain why SSTF scheduling tends to favor middle cylindersover theinnermost and outermost cylinders.The center of the disk is the location having the smallest average distance to all other tracks.Thus the disk head tends to move away from the edges of the disk.Here is another way to think of it.The current location of the head divides the cylinders into two groups.If the head is not in the center of the disk and a new request arrives,the new request is more likely to be in the group that includes the center of the disk;thus,the head is more likely to move in that direction.10.11、Suppose that a disk drive has 5000 cylinders, numbered 0 to 4999. The drive is currently serving a request at cylinder 143, and the previous request was at cylinder 125. The queue of pending requests, in FIFO order, is86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130Starting from the current head position, what is the total distance (in cylinders) that the disk arm moves to satisfy all the pending requests, for each of the following disk-scheduling algorithms?a. FCFSb. SSTFc. SCANd. LOOKe. C-SCANAnswer:a. The FCFS schedule is 143, 86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130. The total seek distance is 7081.b. The SSTF schedule is 143, 130, 86, 913, 948, 1022, 1470, 1509, 1750, 1774. The total seek distance is 1745.c. The SCAN schedule is 143, 913, 948, 1022, 1470, 1509, 1750, 1774, 4999, 130, 86. The total seek distance is 9769.d. The LOOK schedule is 143, 913, 948, 1022, 1470, 1509, 1750, 1774, 130, 86. The total seek distance is 3319.e. The C-SCAN schedule is 143, 913, 948, 1022, 1470, 1509, 1750, 1774, 4999, 86, 130. The total seek distance is 9813.f. (Bonus.) The C-LOOK schedule is 143, 913, 948, 1022, 1470, 1509, 1750, 1774, 86, 130. The total seek distance is 3363.12CHAPTERFile-SystemImplementationPractice Exercises12.1 Consider a file currently consisting of 100 blocks. Assume that the filecontrol block (and the 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) allocation strategies, if, for one block, the following conditions hold. In the contiguous-allocation case, assume that there is no room to grow atthe beginning but there is room to grow at the end. Also assume thatthe block information to be added is stored in memory.a. The block is added at the beginning.b. The block is added in the middle.c. The block is added at the end.d. The block is removed from the beginning.e. The block is removed from the middle.f. The block is removed from the end.Answer:The results are:Contiguous Linked Indexeda. 201 1 1b. 101 52 1c. 1 3 1d. 198 1 0e. 98 52 0f. 0 100 012.2 What problems could occur if a system allowed a file system to be mounted simultaneously at more than one location?Answer:4344 Chapter 12 File-System ImplementationThere would be multiple paths to the same file, which could confuse users or encourage mistakes (deleting a file with one path deletes thefile in all the other paths).12.3 Wh y must the bit map for file allocation be kept on mass storage, ratherthan in main memory?Answer:In case of system crash (memory failure) the free-space list would notbe lost as it would be if the bit map had been stored in main memory.12.4 Consider a system that supports the strategies of contiguous, linked, and indexed allocation. What criteria should be used in deciding which strategy is best utilized for a particular file?Answer:•Contiguous—if file is usually accessed sequentially, if file isrelatively small.•Linked—if file is large and usually accessed sequentially.• Indexed—if file is large and usually accessed randomly.12.5 One problem with contiguous allocation is that the user must preallocate enough space for each file. If the file grows to be larger than thespace allocated for it, special actions must be taken. One solution to this problem is to define a file structure consisting of an initial contiguous area (of a specified size). If this area is filled, the operating system automatically defines an overflow area that is linked to the initial contiguous area. If the overflow area is filled, another overflow areais allocated. Compare this implementation of a file with the standard contiguous and linked implementations.Answer:This method requires more overhead then the standard contiguousallocation. It requires less overheadthan the standard linked allocation. 12.6 How do caches help improve performance? Why do systems not use more or larger caches if they are so useful?Answer:Caches allow components of differing speeds to communicate moreefficiently by storing data from the slower device, temporarily, ina faster device (the cache). Caches are, almost by definition, more expensive than the device they are caching for, so increasing the numberor size of caches would increase system cost.12.7 Why is it advantageous for the user for an operating system todynamically allocate its internal tables? What are the penalties to the operating system for doing so?Answer:Dynamic tables allow more flexibility in system use growth — tablesare never exceeded, avoiding artificial use limits. Unfortunately, kernelstructures and code are more complicated, so there is more potentialfor bugs. The use of one resource can take away more system resources (by growing to accommodate the requests) than with static tables.Practice Exercises 4512.8 Explain how the VFS layer allows an operating system to support multiple types of file systems easily.Answer:VFS introduces a layer of indirection in the file system implementation.In many ways, it is similar to object-oriented programming techniques. System calls can be made generically (independent of file system type). Each file system type provides its function calls and data structuresto the VFS layer. A system call is translated into the proper specific functions for the target file system at the VFS layer. The calling program has no file-system-specific code, and the upper levels of the system callst ructures likewise are file system-independent. The translation at the VFS layer turns these generic calls into file-system-specific operations.。
计算机操作系统课后习题答案解析张尧学
第一章绪论1.什么是操作系统的基本功能?答:操作系统的职能是管理和控制汁算机系统中的所有硬、软件资源,合理地组织计算机工作流程,并为用户提供一个良好的工作环境和友好的接口。
操作系统的基本功能包括:处理机管理、存储管理、设备管理、信息管理(文件系统管理)和用户接口等。
2.什么是批处理、分时和实时系统?各有什么特征?答:批处理系统(batchprocessingsystem):操作员把用户提交的作业分类,把一批作业编成一个作业执行序列,由专门编制的监督程序(monitor)自动依次处理。
其主要特征是:用户脱机使用计算机、成批处理、多道程序运行。
分时系统(timesharingoperationsystem):把处理机的运行时间分成很短的时间片,按时间片轮转的方式,把处理机分配给各进程使用。
其主要特征是:交互性、多用户同时性、独立性。
实时系统(realtimesystem):在被控对象允许时间范围内作出响应。
其主要特征是:对实时信息分析处理速度要比进入系统快、要求安全可靠、资源利用率低。
3.多道程序(multiprogramming)和多重处理(multiprocessing)有何区别?答;多道程序(multiprogramming)是作业之间自动调度执行、共享系统资源,并不是真正地同时值行多个作业;而多重处理(multiprocessing)系统配置多个CPU,能真正同时执行多道程序。
要有效使用多重处理,必须采用多道程序设计技术,而多道程序设计原则上不一定要求多重处理系统的支持。
6.设计计算机操作系统时与那些硬件器件有关运算器、控制器、存储器、输入设备、输出设备第二章作业管理和用户接口2.作业由哪几部分组成?各有什么功能?答:作业由三部分组成:程序、数据和作业说明书。
程序和数据完成用户所要求的业务处理工作,作业说明书则体现用户的控制意图。
3.作业的输入方式有哪几种?各有何特点答:作业的输入方式有5种:联机输入方式、脱机输入方式、直接耦合方式、SPOOLING(Simultaneous Peripheral OperationsOnline)系统和网络输入方式,各有如下特点:(1)联机输入方式:用户和系统通过交互式会话来输入作业。
操作系统第1章练习题
第1章操作系统引论1.1 典型例题解析【例1】试说明操作系统与硬件、其它系统软件以及用户之间的关系。
答:操作系统是覆盖在硬件上的第一层软件,它管理计算机的硬件和软件资源,并向用户提供良好的界面。
操作系统与硬件紧密相关,它直接管理着硬件资源,为用户完成所有与硬件相关的操作,从而极大地方便了用户对硬件资源的使用,并提高了硬件资源的利用率。
操作系统是一种特殊的系统软件,其它系统软件与运行在操作系统地基础之上,可获得操作系统提供的大量服务,也就是说,操作系统是其它系统软件和硬件的接口。
而一般用户使用计算机除了需要操作系统支持外,还需要用到大量的其它系统软件和应用软件,以使其工作更加方便和高效。
【例2】操作系统具有哪些特征?它们之间有何关系?答:操作系统的特征有并发、共享、虚拟和异步性。
它们的关系如下:(1)并发和共享是操作系统最基本的特征。
为了提高计算机资源的利用率,操作系统必然要采用多道程序设计技术,使多个程序共享系统的资源,并发的执行。
(2)并发和共享互为存在的条件。
一方面,资源的共享以程序(进程)的并发执行为条件,若系统不允许程序并发执行,自然不存在资源的共享问题;另一方面,若系统不能对资源共享实施有效管理,协调好各个进程对共享资源的访问,也必将影响到程序的并发执行,甚至根本无法并发执行。
(3)虚拟以并发和共享为前提条件。
为了使并发进程能更方便、更有效地共享资源,操作系统经常采用多种虚拟技术来在逻辑上增加CPU和设备的数量以及存储器的容量,从而解决众多并发进程对有限的系统资源的竞争问题。
(4)异步性是并发和共享的必然结果。
操作系统允许多个并发进程共享资源、相互合作,使得每个进程的运行过程受到其他进程的制约,不再“一气呵成”,这必然导致异步性特征的产生。
【例3】简述并发与并行的区别。
答:并行性和并发性是既相似又有区别的两个概念。
并行性是指两个或多个事件在同一时刻发生;而并发性是指两个或多个事件在同一时间间隔内发生。
操作系统习题集(南京晓庄学院操作系统习题答案)解析
操作系统基础习题解析及实验指导第一篇操作系统基础知识点及习题解答该部分罗列操作系统基础各章节的学习要点,指出学习的重点和难点,在回顾相关知识点的基础上,对典型习题进行分析和解答。
第一章操作系统引论本章学习要点【1】掌握操作系统的概念与作用【2】掌握操作系统的基本类型与特点【3】掌握操作系统的特征与功能【4】深入领会多道程序设计技术本章学习难点【1】多道程序设计技术【2】操作系统的特征知识点回顾一. 操作系统的概念一个完整的计算机系统由计算机硬件系统和计算机软件系统两部分组成。
操作系统是配置在计算机硬件上的第一层软件,是对硬件系统功能的第一次扩充。
图1-1 计算机系统的层次图1.操作系统(Operating System,简称OS)的作用(1)OS作为用户与计算机硬件系统之间的接口OS处于用户与计算机硬件系统之间,用户通过OS来使用计算机系统。
或者说,用户在OS 的帮助下能够方便、快捷、安全、可靠地操纵计算机硬件和运行自己的程序。
(2)OS作为计算机系统资源的管理者这是广为流行的一个关于OS作用的观点。
在一个计算机系统中,通常都包含了各种各样的硬件和软件资源。
归纳起来可将资源分为四类:处理器、存储器、I/O设备以及信息(数据和程序)。
OS的主要功能正是针对这四类资源进行有效的管理。
(3)OS用作扩充机器对于一台完全没有软件配置的计算机系统(裸机),即使功能再强,也必定难于使用。
OS在第 1 页共102 页裸机上分别覆盖I/O设备管理软件、文件管理软件等,此时用户所看到的机器,将是一台比裸机功能更强、使用更方便的机器。
通常把覆盖了软件的机器称为扩充机器或虚机器。
在计算机系统上覆盖上一层软件后,系统功能便增强一级。
由于OS自身包含了若干层软件,因此当在裸机上覆盖上OS后,便可获得一台功能显著增强,使用极为方便的多层扩充机器或多层虚机器。
2.操作系统的概念操作系统是一组控制和管理计算机硬件和软件资源、合理组织计算机的工作流程,方便用户使用的程序的集合。
(完整word版)计算机操作系统典型例题解析之一
计算机操作系统典型例题解析之一【例1】操作系统是对()进行管理的软件.A、软件B、硬件C、计算机资源D、应用程序分析:操作系统是系统的一个系统软件,不但管理计算机系统的硬件资源,还管理软件资源,是整个计算机系统的硬、软件资源的总指挥部,所以本题的答案是C.【例2】从用户的观点看,操作系统是()A、用户与计算机硬件之间的接口B、控制和管理计算机资源的软件C、合理地组织计算机工作流程的软件D、计算机资源的管理者分析:研究操作系统有多种观点,有软件的观点、计算机系统资源管理的观点、进程的观点、虚机器观点、服务提供者观点以及用户的观点。
从用户的观点看,操作系统是用户与计算机硬件系统之间接口。
所以本题的答案是A。
【例3】如果分时操作系统的时间片一定,那么( ),则响应时间越长。
A、用户数越少B、用户数越多C、内存越少D、内存越多分析:在分时系统中采用了分时技术,即把处理机的时间划分成很短的时间片(如几百毫秒),轮流地分配给各个终端作业使用。
若在分配给它的时间片内,作业没有执行完,它必须将CPU交给下一个作业使用,并等下一轮得到CPU时再继续执行。
系统的响应时间和用户的数量成反比,即用户数越多,响应时间越长。
所以本题的答案是B。
【例4】并发和是操作系统的两个最基本的特征,两者之间互为存在条件。
分析:操作系统共有四个主要特征:并发、共享、虚拟和异步性。
其中并发和共享是操作系统最基本的特征。
一方面,资源的共享以程序(进程)的并发执行为条件,若系统不允许程序并发执行,自然不存在资源共享问题;另一方面,若系统不能对资源共享实施有效管理,协调好诸进程对共享资源的访问,也必将影响程序的并发执行,甚至根本无法并发执行。
所以本题的答案是:共享。
【例5】如果操作系统在用户提交作业后,不提供交互能力,它所追求的是计算机资源的高利用率,大吞吐量和作业流程的自动化,则属于类型;如果操作系统具有很强的交互性,可同时供多个用户使用,但时间响应不太及时,则属于类型;如果操作系统可靠性高,时间响应及时,但仅有简单的交互能力则属于类型。
操作系统复习题(附答案与解析)
一、选择题1. 计算机启动是执行的一个程序是()。
A.引导扇区B.bootC.BIOS D.Load解析:CPU加电后会首先执行BIOS程序,其中POST加电自检程序是执行的第一个例行程序。
2. 执行进程调度就是()。
A.一号变迁B.二号变迁C.三号变迁D.四号变迁解析:进程调度就是就绪态到执行态,也就是一号变迁3. 操作系统的主要功能是管理计算机的()A.进程B.作业C.进程和数据D.资源解析:操作系统是为了合理组织计算机工作流程,管理分配计算机系统的硬件和软件资源最大限度地提高计算机系统的利用率。
4. 属于内中断的是()A.内存校验错B.进程缺页C.设备完成了任务D.键盘输入一个字符解析:处理机外部发生的中断叫外中断,当前进程发生的中断叫内中断。
5. 进程运行的三种基本状态是指()A.就绪、执行、阻塞B.就绪、执行、挂起C.就绪、执行、死锁D.就绪、执行、停止6. 产生死锁的4个必要条件是互斥、()、请求与保持、环路等待。
A.请求与阻塞B.不剥夺C.请求与释放D.阻塞与释放7.()是指程序员发出命令到系统给出结果的时间间隔A.响应时间B.周转时间C.等待时间D.运行时间8.()淘汰算法的淘汰次数最少。
A.最不经常使用B.先进先出C.最佳D.最近最少用解析:最佳页面置换算法具有最低缺页率,算法无法实现,但是可以去评价其他算法。
最佳页面置换算法、先进先出页面置换算法、最近最少使用页面置换算法、最近未使用置换算法NRU 、时钟页面置换算法、二次机会页面置换法9. 不需要用缓冲技术的是()A.输入速率> 输出速率B.输入速率< 输出速率C.输入速率!= 输出速率D.输入速率== 输出速率解析:缓冲是为了缓和CPU与I/O设备速度不匹配的矛盾,提高CPU和I/O 设备的并行性。
10. 用硬盘模拟打印机属于()设备。
A.共享B.虚拟C.独占D.块解析;模拟体现了虚拟性。
11. 与计算机硬件直接打交道的是()A.操作系统B.编译系统C.系统应用程序D.命令处理程序解析:操作系统是用户与计算机硬件系统之间的接口12. 嫦娥三号的操作系统spaceOS2是()A.批处理操作系统B.实时操作系统C.分时操作系统D.网络操作系统解析:实时操作系统比分时操作系统可靠,专门用于特定的处理,如航天。
(完整版)操作系统教程第5版课后答案解析
操作系统教程第5版课后答案费祥林、骆斌编著第一章操作系统概论习题一一、思考题1.简述现代计算机系统的组成及层次结构。
答:现代计算机系统由硬件和软件两个部分组成。
是硬件和软件相互交织形成的集合体,构成一个解决计算问题的工具。
硬件层提供基本可计算的资源,包括处理器、寄存器、内存、外存及I/O设备。
软件层由包括系统软件、支撑软件和应用软件。
其中系统软件是最靠近硬件的。
2、计算机系统的资源可分成哪几类?试举例说明。
答:包括两大类,硬件资源和信息资源。
硬件资源分为处理器、I/O设备、存储器等;信息资源分为程序和数据等。
3.什么是操作系统?操作系统在计算机系统中的主要作用是什么?答:操作系统是一组控制和管理计算机硬件和软件资源,合理地对各类作业进行调度,以及方便用户使用的程序的集合。
操作系统在计算机系统中主要起4个方面的作用。
(1)服务用户观点——操作系统提供用户接口和公共服务程序(2)进程交互观点——操作系统是进程执行的控制者和协调者(3)系统实现观点——操作系统作为扩展机或虚拟机(4)资源管理观点——操作系统作为资源的管理者和控制者4.操作系统如何实现计算与操作过程的自动化?答:大致可以把操作系统分为以下几类:批处理操作系统、分时操作系统、实时操作系统、网络操作系统和分布式操作系统。
其中批处理操作系统能按照用户预先规定好的步骤控制作业的执行,实现计算机操作的自动化。
又可分为批处理单道系统和批处理多道系统。
单道系统每次只有一个作业装入计算机系统的主存储器运行,多个作业可自动、顺序地被装入运行。
批处理多道系统则允许多个作业同时装入主存储器,中央处理器轮流地执行各个作业,各个作业可以同时使用各自所需的外围设备,这样可以充分利用计算机系统的资源,缩短作业时间,提高系统的吞吐率5.操作系统要为用户提供哪些基本的和共性的服务?答:(1)创建程序和执行程序;(2)数据I/O和信息存取;(3)通信服务;(4)差错检测和处理。
操作系统原理习题解析
第1章 引 论
一. 单项选择题解析 1. A。2. C。3. D。4. A。5. A。6. C。7. C。8. C。9. C。10. D。11. D。12. D。13. C。14. D。 15. B。16. C。17. D。18. D。19. C。20. B。21. C。22. B。 二. 判断题解析 1. 错误 2. 错误 3. 错误 4. 错误 5. 错误 6. 错误 7. 正确。8. 错误。9. 错误。10. 错误。 11. 正确。12. 错误。13. 正确。14. 错误。15. 错误 16. 正确。17. 错误。18. 错误 19. 正 确。20. 正确。21. 正确。 三. 简答题解析 1. 操作系统具有以下 4 个基本特征: (1)并发性。并发性是指两个或两个以上的事件或活动在同一时间间隔内发生。也即, 宏观上在一段时间内有多道程序在同时运行,微观上这些程序是在交替执行。 (2)共享性。因程序的并发执行而使系统中的软、硬件资源不再为某个程序所独占,而 是由多个程序共同使用(共享) 。 (3)虚拟性。多道程序设计技术把一台物理计算机虚拟为多台逻辑上的计算机,使得每 个用户都感觉是“独占”计算机。 (4)不确定性。多道程序系统中各程序之间存在着直接或间接的联系,并且受资源等因 素的限制,程序的推进速度受到其他程序的影响。这样,程序运行的顺序、程序完成的时间 以及程序运行的结果都是不确定的。 2 多道程序设计技术是指把多个程序同时存入内存并允许它们交替执行和共享系统中的 各类资源;当一道程序因某种原因(如 I/O 请求)而暂停执行时,CPU 立即转去执行另一道 程序。多道程序设计技术的主要特点是:多道、宏观上并行、微观上串行。多道是指计算机 内存中同时存放多道相互独立的程序; 宏观上并行是指同时进入系统中的多道程序都处于运 行的过程中; 微观上串行是指在单 CPU 环境中, 内存中的多道程序轮流占用 CPU 交替执行。 3. 要保证多道程序的正常运行,在技术上需要解决如下问题: (1)在多道程序之间应如何分配 CPU,使得 CPU 既能满足各程序运行的需要,又能有 较高的利用率。此外,一旦将 CPU 分配给某程序后,应何时回收。 (2)如何为每道程序分配必要的内存空间,使它们各得其所但又不会因相互重叠而丢失 信息;此外,还要防止因某道程序出现异常情况而破坏其他程序。 (3)系统中可能有多种类型的 I/O 设备供多道程序共享,应如何分配这些 I/O 设备,如 何做到既方便用户对设备的使用,又能提高设备的利用率。 (4)在现代计算机系统中通常都存放着大量的程序和数据,应如何组织它们才便于用户 使用并保证数据的安全性和一致性。 (5)系统中的各种应用程序有的属于计算型、有的属于 I/O 型,有些既重要又紧迫、有 些又要求系统能及时响应,这时系统应如何组织这些程序(作业)的工作流程。 实际上,这些问题的全体就是操作系统的核心内容。 4. 在单道程序环境下,由于程序独占全机软、硬件资源且完全是在一个封闭环境中运行, 所以如果使用相同的输入,则多次运行的结果必然相同。 引入多道程序技术后,由于多道程序共享全机软、硬件资源,即各程序之间存在着直接 或间接的联系,并受资源等因素的制约;此时程序的运行就不是在一个封闭的环境下,而要 受到其他程序和系统资源的影响, 这会引起程序运行的结果、 程序执行的顺序和完成的时间 都不确定。此外,在多道程序环境下,外部设备的中断、输入输出的请求等出现的时间都是 不确定的。 这些不确定因素给操作系统设计带来了很大的复杂性。 对于程序执行结果的不确 定是绝对不允许的, 这是操作系统必须解决的主要问题; 而程序执行顺序及完成时间的不确
操作系统习题分析
经典生产者—消费者问题
• 设置信号量
– 公用信号量mutex:保证生产者进程和消费者进程之 间的互斥;初值为1,表示没有进程进入临界区 – 私用信号量avail:生产者进程的私用信号量,表示可 用缓冲区数,初值为n – 私用信号量full:消费者进程的私用信号量,表示产品 数目,初值为 0
生产者进程
各程序内部计算和I/O操作的时间
解:多道程序系统中,在处理机调度程序管理下 各程序状态转换的时间关系图如图2所示。
图2 各程序执行与状态转换的时间关系图 单道系统中,三道程序共运行的时间为:
T=60+2+30+2+40+2+50+2+20+2+50+2+70+2+50+2+40+2+30+2+20+2
输入进程R 打印进程P
缓冲区
3.6 进程同步
例,共享一个缓冲区的合作进程
计算进程PC
缓冲区
打印进程PP
计算进程PC :反复地把每次计算结果放入缓冲区Buf中 打印进程PP :将计算进程每次放入缓冲区Buf中的数据 取出,通过打印机打印输出 缓冲区Buf :一次只可放一个数据
Begin Sc,Sp: semaphore; Sp=0; /*信号量Sp,表示缓冲区Buf 是否存放计算结果*/ Sc=1; /*信号量Sc,表示缓冲区Buf 是否为空*/ Cobegin Pc: While (计算未结束); /*计算进程*/ { 计算; P(Sc); /*缓冲区是否为空?若非空,则等待*/ Buf←计算结果; V(Sp); } Pp: While (打印未完成); /*打印进程*/ { P(Sp); /*缓冲区是否为数据?若无,则等待*/ 从缓冲区Buf取数据; V(Sc); 打印数据; } Coend End
操作系统第五版费祥林_课后习题答案解析参考
第一章操作系统概论1、有一台计算机,具有IMB 内存,操作系统占用200KB ,每个用户进程各占200KB 。
如果用户进程等待I/O得时间为80 % ,若增加1MB 内存,则CPU 得利用率提高多少?ﻫ答:设每个进程等待I/O 得百分比为P ,则n 个进程同时等待刀O 得概率就是Pn ,当n个进程同时等待I/O 期间CPU 就是空闲得,故CPU 得利用率为1-Pn。
由题意可知,除去操作系统,内存还能容纳4个用户进程,由于每个用户进程等待I/O得时间为80 % , 故:CPU利用率=l-(80%)4 = 0、59若再增加1MB内存,系统中可同时运行9 个用户进程,此时:cPu 利用率=l-(1—80%)9 = 0、87 ﻫ故增加IMB 内存使CPU得利用率提高了47 %:87 %/59 %=147 %147 %-100 % = 47 %2 一个计算机系统,有一台输入机与一台打印机,现有两道程序投入运行,且程序A 先开始做,程序B 后开始运行.程序A 得运行轨迹为:计算50ms 、打印100ms 、再计算50ms 、打印100ms ,结束。
程序B 得运行轨迹为:计算50ms、输入80ms 、再计算100ms ,结束。
试说明(1 )两道程序运行时,CPU有无空闲等待?若有,在哪段时间内等待?为什么会等待?( 2 )程序A、B 有无等待CPU得情况?若有,指出发生等待得时刻。
答:(1)两道下:ﻫﻫ程序运行期间,CPU存在空闲等待,时间为100 至150ms之间(见图中有色部分)ﻫ(2)程序A 无等待现象,但程序B 有等待。
程序B 有等待时间段为180rns至200ms 间(见图中有色部分)ﻫ3设有三道程序,按A 、B 、C优先次序运行,其内部计算与UO操作时间由图给出.ﻫ试画出按多道运行得时间关系图(忽略调度执行时间)。
完成三道程序共花多少时间?比单道运行节省了多少时间?若处理器调度程序每次进行程序转换化时lms , 试画出各程序状态转换得时间关系图。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
已知一个求值公式(A2+3B)/(B+5A),若A,B已赋值,试画 出该公式求值过程的前趋图,并用信号量解决公式的求解过程。
开始
S1:x1=A*A S2:x2=3*B S3:x3=5*A
S4:x4=x1+x2
S5:x5=B+x3
S6:x6=x4/x5
S1
S2
S4
结束
S6
S3 S5
struct semaphore a,b,c,d,e,=0,0,0,0,0;
注意初值avail的设置,n不正确
dad
mom
P(avail); P(avail);
P(mutex); P(mutex);
put an apple; put an orange;
Hale Waihona Puke V(appfull); V(orgfull);
V(mutex); V(mutex);
dau P(appfull); P(mutex); get an apple; V(avail); V(mutex);
V(so); }
}
void son (void) { while(TRUE){ P(so); get an orange; V(s); eat an orange;} }
void daught (void) { while(TRUE){ P(sp); get an apple; V(s); eat an apple;} }
cobegin
son(void) father(void)
mother(void) begin
begin
begin
P(orange); P(platempty);
P(platempty); P(plate);
P(plate);
P(plate);
吃桔子;
放苹果;
桔子放入盘中; V(platempty);V(apple);
启动车辆
上下乘客
正常行车
关车门
到站停车
售票
开车门
上下乘客
在汽车不断到站,停车,行驶过程中,这两个活动的同步关系。
S1是否可以开车门 S2是否可以发动车辆
struct semaphore s1,s2=0,0; cobegin void driver(void)
{ while(TRUE){ p(s2); 启动车辆; 正常行车; 到站停车; V(s1);}
struct semaphore s,sp,so=1,0,0; cobegin void father (void)
{ while(TRUE){
have an apple; P(s); put an apple; V(sp); } }
void mother (void) { while(TRUE){ have an orange; P(s); put an orange;
son P(orgfull); P(mutex); get an apple; V(avail); V(mutex);
Begin P(apple); P(pan) V(apple); V(pan); P(orange); P(pan); V(orange); V(pan);
P(pan); P(apple); V(apple); V(apple); V(pan); P(pan); P(orange); V(orange); V(pan);
A:2 B:3 C:4 4.分时系统的响应时间(及时性)主要是根据(A)确定的,而试试系统的响应时间 则是由(B)确定的。 A,B:(1)时间片大小;(2)用户数目;(3)计算机运行速度;(4)用户所能 接受的等待时间;(5)控制对象所能接受的时延;(6)实时调度。
A:4 B:5 5.采用(A)结构时,将OS分成用于实现OS最基本功能的内核和提供各种服务的服 务器两个部分。通常,下列模块中必须包含在操作系统内核中的是(B)模块。 A:(1)整体式;(2)模块化;(3)层次式;(4)微内核。 B:(1)内存分配;(2)中断处理;(3)文件处理;(4)命令处理。
V(orange); V(plate); V(plate);
V(plate);
end
end
end
mother(void) begin P(apple); P(plate); 吃苹果; V(platempty); V(plate); end coend
设公共汽车上,司机和售票员的活动分别是:
司机:
售票员:
启动车辆;
正常行车;
到站停车;
V(s1);}
}
void conductor(void)
{
while(TRUE){
P(s1);
开车门;
上、下乘客;
关车门;
V(s2);
售票;}
}
coend
司机-售票员问题另解:
S1是否可以开车门=1 S2是否可以发动车辆=0
1.在某系统中,三个进程共享四台设备资源,这些资源 一次只能一台地为进程服务和释放,每个进程最多需要 二台设备资源,试问在系统中是否会产生死锁?
A:2 B:3 C:4 D:1
2.操作系统有多种类型:允许多个用户以交互方式使用计算机的操作系统称为(A); 允许多个用户将若干个作业提交给计算机系统集中处理的操作系统称为(B);在 (C)的控制下,计算机系统能及时处理由过程控制反馈的数据,并做出响应;在IBM -PC机上的操作系统称为(D)。 A,B,C,D:(1)批处理操作系统;(2)分时操作系统;(3)实时操作系统;(4)
coend
Plate 1 爸私 applempty 盘中无苹果 1 女私applefull盘中有苹果0 妈私orangempty无桔子1 儿私orangefull有桔子0
爸
女
{
{
p(plate);
P(applempty); p(applefull);
放苹果;
P(plate);
V(applefull); 取苹果;
V(plate); }
V(applempty); }
母 { p(plate); P(orangempt
y); 放桔子; V(orangefull); V(plate); }
儿 { p(orangefull); P(plate); 取桔子; V(plate); V(orangempty); }
mutex 盘子 a表示爸爸是否在盘中放入苹果 b 女儿是否可吃苹果 c表示妈妈是否在盘中放桔子 d为儿子是否可吃桔子
母 S2:parbegin P(empty); count:=count+1; V(orange); do sth else parend
女 S4:parbegin P(apple); count:=count-1; If(count=0) V(empty); do sth else parend
struct semphore plate,platempty,orange,apple=1,1,0,0;
答:不会。若所有的资源都被占用,而占用者又都不满 足必须的全部资源,此时就有一个或几个进程无限期地 等待更多的资源,系统就会出现死锁。本题中若4 台设 备资源都被占用,则其中一定有一个进程获得2台设备资 源(满足其最大的需求量),这个进程必然会在有限的时 间内完成其工作,并释放其所占用的2台资源, 这样也 就能满足其它二进程对设备资源的要求,继续完成它们 各自的工作。
}
void conductor(void) { while(TRUE){ 上、下乘客;关车门; V(s2); 售票; P(s1); 开车门;上、下乘客;} }
coend
struct semaphore s1,s2=1,0;
cobegin
void driver(void)
{
while(TRUE){
P(s2);
微机操作系统;(5)多处理机操作系统。
A:2 B:1 C:3 D:4
3.在设计分时操作系统时,首先要考虑的是(A);在设计批处理操作系统时,先 要考虑的是(B);在设计实时操作系统时,首先要考虑的是(C)。 A,B,C:(1)灵活性和可适应性;(2)交互性和响应时间;(3)周转时间和 系统吞吐量;(4)实时性和可靠性。
习题选讲与解析
一、选择题 1.在计算机系统中配置操作系统的主要目的是(A)。操作系统的主要功能是管理
计算机系统中的(B),其中包括(C)、(D),以及文件和设备。这里的(C)管 理主要是对进程进行管理。 A:(1)增强计算机系统的功能;(2)提高系统资源的利用率;(3)提高系统的运
行速度;(4)合理组织系统的工作流程,以提高吞吐量。 B:(1)程序和数据;(2)进程;(3)资源;(4)作业;(5)软件;(6)硬件。 C,D:(1)存储器;(2)虚拟存储器;(3)运算器;(4)处理机;(5)控制器。
操作系统中所谓的”虚拟“,是指通过某种技术把一个物理实体变为若干个逻辑上
的对应物,相应的用于实现虚拟的技术称为虚拟技术。在操作系统中利用了多种虚拟技
术分别用来实现虚拟处理机、虚拟内存、虚拟外设和虚拟信道等。虚拟的实现主要是通
过分时技术,例如,多道程序系统中,通过分时技术来实现虚拟处理机;将一台物理处
cobegin
{S1;V(a);}
{S2;V(b);}
{S3;V(c) ;}
S1
{P(a);P(b);S4;V(d)} a
S2
b
S3
c
{P(c);S5;V(e);} {P(d);P(e);S6);} coend
S4
S5
d
e
S6
吃水果问题
问题描述:桌上有一只盘子,每次只能放一个水果,爸爸专向盘中放苹果,妈妈专向盘 中放桔子,儿子专等吃盘里的桔子,女儿专等吃盘里的苹果。只要盘子空,则爸爸或妈 妈可向盘中放水果,仅当盘中有自己需要的水果时,儿子或女儿可从中取出,请给出四 人之间的同步关系,并用P、V操作实现四人正确活动的程序。