操作系统习题分析

合集下载

操作系统习题解答

操作系统习题解答

操作系统习题解答1.存储程序式计算机的主要特点是什么?答:主要特点是以顺序计算为基础,根据程序规定的顺序依次执行每一个操作,控制部件根据程序对整个计算机的活动实行集中过程控制,即为集中顺序过程控制。

这类计算是过程性的,实际上这种计算机是模拟人们的手工计算的产物。

即首先取原始数据,执行一个操作,将中间结果保存起来;再取一个数,和中间结果一起又执行一个操作,如此计算下去。

在遇到多个可能同时执行的分支时,也是先执行完一个分支,然后再执行第二个分支,直到计算完毕。

2.批处理系统和分时系统各具有什么特点?答:批处理系统是在解决人—机矛盾以及高速度的中央处理机和低速度的I/O设备这两对矛盾的过程中发展起来的。

它的出现改善了CPU和外设的使用情况,其特点是实现了作业的自动定序、自动过渡,从而使整个计算机系统的处理能力得以提高。

在多道系统中,若采用了分时技术,就是分时操作系统,它是操作系统的另一种类型。

它一般采用时间片轮转的办法,使一台计算机同时为多个任务服务。

对用户都能保证足够快的响应时间,并提供交互会话功能。

它与批处理系统之间的主要差别在于,分时系统是人机交互式系统,响应时间快;而批处理系统是作业自动定序和过渡,无人机交互,周转时间长。

3.实时系统的特点是什么?一个实时信息处理系统和一个分时系统从外表看来很相似,它们有什么本质的区别呢?答:实时系统对响应时间的要求比分时系统更高,一般要求响应时间为秒级、毫秒级甚至微秒级。

将电子计算机应用到实时领域,配置上实时监控系统,便组成各种各样的专用实时系统。

实时系统按其使用方式不同分为两类:实时控制系统和实时信息处理系统。

实时控制是指利用计算机对实时过程进行控制和提供监督环境。

实时信息处理系统是指利用计算机对实时数据进行处理的系统。

实时系统大部分是为特殊的实时任务设计的,这类任务对系统的可靠性和安全性要求很高。

与分时系统相比,实时系统没有那样强的交互会话功能,通常不允许用户通过实时终端设备去编写新的程序或修改已有的程序。

操作系统练习题_及答案解析

操作系统练习题_及答案解析

操作系统练习题第一章引言(一单项选择题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技术用于( 。

(完整版)操作系统第五版费祥林_课后习题答案解析参考

(完整版)操作系统第五版费祥林_课后习题答案解析参考

第一章操作系统概论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.下面不属于操作系统的是(C )A、OS/2B、UCDOSC、WPSD、FEDORA2.操作系统的功能不包括(B )A、CPU管理B、用户管理C、作业管理D、文件管理3.在分时系统中,当时间片一定时,(B ),响应越快。

A、内存越大B、用户越少C、用户越多D、内存越小4.分时操作系统的及时性是指( B )A、周转时间B、响应时间C、延迟时间D、A、B和C5.用户在程序设计的过程中,若要得到系统功能,必须通过(D )A、进程调度B、作业调度C、键盘命令D、系统调用6.批处理系统的主要缺点是( C )A、CPU使用效率低B、无并发性C、无交互性D、都不是第二章1、若信号量的初值为2,当前值为-3,则表示有(C )个进程在等待。

A、1B、2C、3D、52、在操作系统中,要对并发进程进行同步的原因是(B )A、进程必须在有限的时间内完成B、进程具有动态性C、并发进程是异步的D、进程具有结构性3、下列选项中,导致创进新进程的操作是(C )I用户成功登陆II设备分配III启动程序执行A、仅I和IIB、仅II和IIIC、仅I和IIID、I,II,III4、在多进程系统中,为了保证公共变量的完整性,各进程应互斥进入临界区。

所谓的临界区是指(D )A、一个缓冲区B、一个数据区C、一种同步机构D、一段程序5、进程和程序的本质区别是(B )A、内存和外存B、动态和静态特征C、共享和独占计算机资源D、顺序和非顺序执行计算机指令6、下列进程的状态变化中,(A )的变化是不可能发生的。

A、等待->运行B、运行->等待C、运行->就绪D、等待->就绪7、能从1种状态变为3种状态的是(D )A、就绪B、阻塞C、完成D、执行8、下列关于进程的描述正确的是(A )A、进程获得CPU是通过调度B、优先级是进程调度的重要依据,一旦确定就不能改变C、在单CPU系统中,任何时刻都有一个进程处于执行状态D、进程申请CPU得不到满足时,其状态变为阻塞9、CPU分配给进程的时间片用完而强迫进程让出CPU,此时进程的状态为(C )。

操作系统习题解答

操作系统习题解答

《操作系统》习题解答习题11.术语解释裸机虚拟机操作系统程序接口命令接口非特权指令特权指令核心态用户态系统调用微内核批处理系统分时实时指令的执行周期中断中断源中断请求中断屏蔽中断禁止GPL POSIX 时间片答案:·未配置任何软件的计算机称为“裸机”。

·在裸机上安装一层软件,使机器的功能得以扩展,这时展现在用户面前的“机器”,就是所谓的虚拟机。

·操作系统是控制和管理计算机硬件和软件资源、合理地组织计算机工作流程以及方便用户使用计算机的一个大型系统软件。

·在用户编写的程序中,可使用系统调用命令获得操作系统提供的各种功能服务,这是操作系统在程序一级给予用户的支持,称其为程序接口。

·用户可使用操作系统提供的各种操作命令,通过键盘(或鼠标)控制和完成程序的运行,这是操作系统在作业控制一级给予用户的支持,称为命令接口。

·操作系统和用户程序都能使用的硬指令,称为非特权指令。

·只能由操作系统使用的硬指令,称为特权指令。

·所谓核心态,是指CPU处于可执行包括特权指令在内的一切机器指令的状态。

·所谓用户态,是指CPU处于只能执行非特权指令的状态。

·操作系统里预先编制了很多不同功能的子程序。

用户在自己的程序里调用这些子程序,以求得操作系统提供的功能服务。

就把这些功能服务子程序称为“系统功能调用”程序,简称“系统调用”。

·微内核即是把操作系统的内核分为基本功能和非基本功能两部分,在内核里只保留基本功能部分,在核心态下运行;非基本功能部分则从内核剥离下来,让它们以各种服务的形式,在用户态下运行。

这一的操作系统内核,称为微内核。

·若在某系统中,用户作业被分批处理,在处理一批的过程中不允许用户与计算机发生交互作用,即使作业在运行中出现错误,也只能等到整批作业处理完毕后在机下修改。

这样的系统,就是所谓的“批处理系统”。

操作系统习题解析

操作系统习题解析
试从交互性、及时性以及可靠性三个方面,比较分时系统与实时系统。P11
已知一个求值公式(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.。

操作系统习题与解答(含答案)

操作系统习题与解答(含答案)

操作系统习题与解答(含答案)第⼀章操作系统引论⼀、选择题1.在计算机系统中配置操作系统的主要⽬的是(),操作系统的主要功能是管理计算机系统中的(),其中包括()管理和()管理,以及设备管理和⽂件管理。

这⾥的()管理主要是对进程进⾏管理。

(1)A.增强计算机系统的功能;B.为了使⽤系统的资源;C.提⾼系统的运⾏速度;D.提⾼系统使⽤效率,合理地组织系统的⼯作流程,以提⾼系统吞吐量。

(2)A.程序和数据;B.进程;C.资源;D.作业;E.任务。

(3)(4)A.存储器;B.虚拟存储器;C.运算器;D.处理机;E.控制器。

2.操作系统有多种类型:(1)允许多个⽤户以交互⽅式使⽤计算机的操作系统,称为();(2)允许多⽤户将若⼲个作业提交给计算机系统集中处理的操作系统称为();(3)在()的控制下,计算机系统能及时处理由过程控制反馈的数据,并做出响应。

A.批处理操作系统;B.分时操作系统;C.实时操作系统;D.微机操作系统;E.多处理机操作系统。

3.在下列性质中,哪⼀个不是分时系统的特征。

()A.交互性B.多路性C.成批性D.独占性4.实时操作系统追求的⽬标是()。

A.⾼吞吐率B.充分利⽤内存C.快速响应D.减少系统开销5. 现代操作系统的两个基本特征是()和资源共享A.多道程序设计B.中断处理C.程序的并发执⾏D.实现分时与实时处理6.引⼊多道程序的⽬的在于()。

A.有利于代码共享,减少主、辅存信息交换量。

B.提⾼实时响应速度。

C.充分利⽤CPU,减少CPU等待时间D.充分利⽤存储器7.操作系统是⼀组().A.⽂件管理程序B.中断处理程序C.资源管理程序D.设备管理程序8.()不是操作系统关⼼的主要问题.A.管理计算机裸机B.设计、提供⽤户程序与计算机硬件系统的界⾯C.管理计算机系统资源D.⾼级程序设计语⾔的编译器9.⽤户在⼀次计算机过程中,或者⼀次事物处理中,要求计算机完成所做的⼯作的集合,这是指().A.进程B.程序C.作业D.系统调⽤10.订购机票系统处理各⾃各个终端的服务请求,处理后通过终端回答⽤户,所以它是⼀个()。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

序管理下各程序状态转换
的时间关系图,并计算出
完成这三道程序共花多少
时间?比单道运行节省了
多少时间?
图1 各程序内部计算和I/O操作的时间
解:多道程序系统中,在处理机调度程序管理下 各程序状态转换的时间关系图如图2所示。
图2 各程序执行与状态转换的时间关系图 单道系统中,三道程序共运行的时间为:
读书;
P(S) 在登记表中查找座位X; 撤消登记信息; 置座位X的标志为空; V(Sn) V(S) end Coend
讨论并分析上述程序:
– 采用指针形式(类似生产者-消费者问题) – 给每个座位设置一个信号量(类似哲学家就餐问
题)
第3章 补充题
3. 桌上有一只盘子,每次只能放入一个水果。爸爸 专向盘中放苹果,妈妈专向盘中放桔子,一个女 儿专等吃盘中的苹果,一个儿子专等吃盘中的桔 子。试用P、V操作写出他们能同步的程序。
输入进程R
处理进程M 打印进程P
缓冲区
3.6 进程同步
例,共享一个缓冲区的合作进程
计算进程PC
缓冲区 打印进程PP
计算进程PC :反复地把每次计算结果放入缓冲区Buf中 打印进程PP :将计算进程每次放入缓冲区Buf中的数据
取出,通过打印机打印输出
缓冲区Buf :一次只可放一个数据
Begin
《操作系统》习题分析
总问题
• 概念要清楚、定义要准确 • 叙述要清楚、具体 • 解题过程要详细 • 有关PV操作的题必须编写程序,给出算法
第1章 补充作业
1、设在内存中有三道程序A、
B和C,并按A、B、C的优
先次序运行,其内部计算
和I/O操作的时间如图1所
示。若处理机调度程序每
次进行程序状态转换的时
• 一个读者一个进程 • 信号量的设置
S:用于读者互斥访问(登记/撤消)登记表,初值为1 Sn:表示空座位数,初值为100
• 每个座位设一个状态位:满/空(类似信箱通讯)
程序
begin S, Sn : Semaphore; S:=1 ; Sn:=100;
Cobegin process Reader i (i=1, 2, …… , n ) begin P(Sn); P(S) ; 选择标志为空的座位X; 登记; 置座位X的标志为满; V(S);
daughter:
son:
Coend end
Repeat P(Sa); 从盘中取出苹果; V(S); 吃苹果;
Until false Repeat
P(So); 从盘中取出桔子; V(S); 吃桔子; Until false
第3章 补充题
4、某大学军训正在进行实弹练习。现有一保管员负责管理 枪支弹药,有A、B两组学生,A组学生每人都有一支枪, B组学生每人都备有足够的子弹,任一学生只要有枪和子 弹就可以进行实弹练习。在打靶场有一个可以放一只枪或 一发子弹的盒子,当盒中无物品时,保管员就可以任意放 一支枪或一发子弹供学生取用。当盒中有学生所需材料时, 每次允许一个学生从中取出自己所需的材料,材料取走后, 保管员再放一件材料。
Pp: Repeat P(Sm); 从缓冲区取出一个记录; V(empty); 打印记录;
Until false Coend end
第3章 进程管理
2.有一阅览室,读者进入时必须先在一张登记表上 进行登记。该表为每一座位列出一个表目,包括 座号、姓名。读者离开时撤消登记信息。阅览室 有100个座位,试问:
Sc,Sp: semaphore; Sp=0; /*信号量Sp,表示缓冲区Buf 是否存放计算结果*/ Sc=1; /*信号量Sc,表示缓冲区Buf 是否为空*/
Cobegin Pc: While (计算未结束); /*计算进程*/ { 计算; P(Sc); /*缓冲区是否为空?若非空,则等待*/ Buf←计算结果;
begin empty, Sr, Sm, Sp : semaphore empty:=1; Sr:=0; Sm:=0 ;
Cobegin Pr: Repeat 从输入设备读一个记录; P(empty); 将记录存入缓冲区; V(Sr); Until false Pm: Repeat P(Sr); 在缓冲区中加工记录; V(Sm); Until false
T=60+2+30+2+40+2+50+2+20+2+50+2+70+2+50+2+40+2+30+2+20+2 =482
多道运行比单道运行节省时间为:482-306=176
第3章 进程管理
• 教材 p83 2、6、7、8、9、10、11、13、14、15
第3章 进程管理
1.设有三个并发进程R、M、P,它们共享一个缓冲 区。R负责从输入设备读信息,每读一个记录后, 就把它存放在缓冲区中;M在缓冲区中加工读入 的记录;P把加工后的记录打印输出。读入的记录 经加工输出后,缓冲区又可存放下一个记录。试 写出它们能正确执行的程序。
V(Sp);
} Pp: While (打印未完成); /*打印进程*/
{ P(Sp); /*缓冲区是否为数据?若无,则等待*/ 从缓冲区Buf取数据;
V(Sc); 打印数据;
}
Coend
End
分析
• 缓冲区是临界资源,必须互斥访问 • 信号量empty:表示缓冲区是否为空,初值为1 • 信号量Sr:进程R是否已输入信息,初值Sr=0 • 信号量Sm:进程M是否已加工信息,初值Sm=0
(1)为描述读者的动作,应编写几个程序, 应该设置几个进程?进程和程序之间的对应关系 如何?
(2)试用P、V操作描述这些进程间的同步 算法。
分析
• 读者动作:登记、读书、撤消 • 座位总数:100 • 登记/撤消都需要在登记表修改信息,一次只能有
一个读者对登记表进行访问 登记表是临界资源,必须互斥访问
分析: • 信号量S:表示盘子是否为空,初值为1 • 信号量So:表示盘中是否有桔子,初值为0 • 信号量Sa:表示盘子是否有苹果,初值为0
程序
begin S, Sa, So : semaphore S=1; Sa=0; So=0; Cobegin father: Repeat P(S); 将苹果放入盘中; V(Sa); Until false mother: Repeat P(S); 将桔子放入盘中; V(So); Until false
相关文档
最新文档