操作系统部分作业参考答案

合集下载

电子科技大学《计算机操作系统》作业考核试题及答案参考

电子科技大学《计算机操作系统》作业考核试题及答案参考

电子科技大学《计算机操作系统》作业考核试题及答案参考第一部分:选择题1. 什么是操作系统?操作系统是计算机系统的一个重要组成部分,它是一种管理计算机硬件和软件资源的系统软件,为用户提供一个操作计算机的环境。

2. 操作系统的主要功能是什么?操作系统的主要功能包括进程管理、文件管理、内存管理、设备管理和网络管理。

3. 进程是指什么?进程是指计算机中正在执行的程序的实例。

每个进程都有自己的内存空间、寄存器和其他系统资源,它们可以并行或交替执行。

4. 什么是进程调度算法?进程调度算法是操作系统使用的一种策略,用于决定哪个进程应当被调度并占用处理器资源。

常见的调度算法有先来先服务、短作业优先、轮转法等。

5. 文件系统是什么?文件系统是操作系统管理计算机存储设备上文件的一种方式,它可以对文件进行存储、组织、管理和访问。

第二部分:简答题1. 请简要解释操作系统的内存管理功能。

操作系统的内存管理功能包括内存分配、内存保护和内存回收。

内存分配是指根据程序的需要,将可用的内存分配给进程;内存保护是指防止一个进程越界访问其他进程或操作系统的内存;内存回收是指当一个进程退出或者不再需要内存时,将其所占用的内存释放出来,以便其他进程使用。

2. 请简要解释死锁是什么,以及如何避免死锁?死锁是指两个或多个进程因为互相等待对方所持有的资源而无法继续执行的状态。

为避免死锁,可以采取以下措施:破坏死锁产生的四个必要条件(互斥条件、请求与保持条件、不剥夺条件、循环等待条件)之一;使用资源分级、资源有序性等算法进行资源分配;按照固定的顺序申请和释放资源,避免循环等待。

3. 请简要解释虚拟内存的概念及其作用。

虚拟内存是一种操作系统的内存管理技术,它可以将物理内存和磁盘的空间组合起来,提供给进程使用。

虚拟内存的作用是扩大了进程的可用地址空间,允许大于实际物理内存的程序运行;并且能够将不常用的数据或程序部分保存到磁盘上,从而释放出物理内存供其他进程使用。

国家开放大学《操作系统》形考任务1参考答案

国家开放大学《操作系统》形考任务1参考答案

国家开放大学《操作系统》形考任务1-3参考答案形考作业1一、单项选择题1.按照所起的作用和需要的运行环境,操作系统属于( )。

A.系统软件B. 应用软件C. 用户软件D. 支撑软件2.UNIX操作系统核心层的实现结构设计采用的是( )。

A.层次结构B. 网状结构C. 微内核结构D. 单块式结构3.UNIX命令的一般格式是( )。

A.[参数] [选项] 命令名B. [选项] [参数] 命令名C. [命令名] [选项] [参数]D.命令名[选项][参数]4.操作系统的基本职能是( )。

A. 提供方便的可视化编辑程序B. 提供功能强大的网络管理工具c. 提供用户界面,方便用户使用D.控制和管理系统内各种资源,有效地组织多道程序的运行5.操作系统对缓冲区的管理属于( )的功能。

A. 处理器管理B. 存储器管理C. 文件管理D. 设备管理6.操作系统内核与用户程序、应用程序之间的接口是( )。

A. C语言函数B.shell命令C. 图形界面D. 系统调用7.工业过程控制系统中运行的操作系统最好是( )。

A.实时系统B. 分时系统C. 网络系统D. 分布式操作系统8.进程从运行状态变为阻塞状态的原因是( )。

A.输入或输出事件发生B. 输入或输出事件完成C. 时间片到D. 某个进程被唤醒9.进程控制块是描述进程状态和特性的数据结构,一个进程( )。

A. 可以没有进程控制块B. 可以有多个进程控制块C. 可以和其他进程共用一个进程控制块D.只能有唯一的进程控制块10.进程与程序之间有密切联系,但又是不同的概念。

二者的一个本质区别是( )。

A. 程序保存在文件中,进程存放在内存中B. 程序是动态概念,进程是静态概念c. 程序顺序执行,进程并发执行D.程序是静态概念,进程是动态概念11.两个进程合作完成一个任务,在并发执行中,一个进程要等待其合作伙伴发来信息,或者建立某个条件后再向前执行,这种关系是进程间的( )关系。

《Linux操作系统》部分习题答案

《Linux操作系统》部分习题答案

第一章Linux系统简介一、思考题1.UNIX的大部分代码是用一种流行的程序设计语言编写的,该语言是什么?C语言2.UNIX系统的特点有哪些?·多任务·多用户·并行处理能力·设备无关性·工具·错误处理·强大的网络功能·开放性3.什么是Linux?其创始人是谁?Linux是一个功能强大的操作系统,同时它也是一个自由软件,是免费的、源代码开放的、可以自由使用的UNIX兼容产品。

其创始人是Linus4.Linux操作系统的诞生、发展和成长过程始终依赖者的重要支柱都有哪些?·UNIX操作系统·MINIX操作系统·GNU计划·POSIX标准·Internet5.简述Linux系统的特点。

·自由软件·良好的兼容性·多用户、多任务·良好的界面·丰富的网络功能·可靠地安全性、稳定性·支持多种平台6.常见的Linux的发行版本有哪些?·Red Hat Linux·Caldera OpenLinux·SuSE Linux·TurboLinux·红旗Linux·中软Linux二、选择题1.Linux最初是以MINIX操作系统为模板而开发出来的。

2.关于Linux内核版本的说法,下列选项中错误的是(C)。

A.表示为主版本号.次版本号.修正号B.1.2.3表示稳定的发行版C.1.3.3表示稳定的发行版D.2.2.5表示对内核2.2的第5次修正(补充:次版本号为偶数的是稳定版本;为奇数的则是测试版本。

)3.Linux属于自由软件。

4.自由软件的含义是软件可以自由修改和发布。

5.一下不具有多任务性的操作系统是DOS第二章Linux系统入门一、思考题1.Linux系统有哪些运行级别?其含义是什么?可用级别为0~6,其中0:关闭系统;6:重新启动,其他略。

操作系统课后部分习题及答案

操作系统课后部分习题及答案

第2章操作系统的运行环境2.2 现代计算机为什么设置目态/管态这两种不同的机器状态?现在的lntel80386设置了四级不同的机器状态(把管态又分为三个特权级),你能说出自己的理解吗?答:现在的Intel 80386把执行全部指令的管态分为三个特权级,再加之只能执行非特权指令的目态,这四级不同的机器状态,按照系统处理器工作状态这四级不同的机器状态也被划分管态和目态,这也完全符合处理器的工作状态。

2.6 什么是程序状态字?主要包括什么内容?答:如何知道处理器当前处于什么工作状态,它能否执行特权指令,以及处理器何以知道它下次要执行哪条指令呢?为了解决这些问题,所有的计算机都有若干的特殊寄存器,如用一个专门的寄存器来指示一条要执行的指令称程序计数器PC,同时还有一个专门的寄存器用来指示处理器状态的,称为程序状态字PSW。

主要内容包括所谓处理器的状态通常包括条件码--反映指令执行后的结果特征;中断屏蔽码--指出是否允许中断,有些机器如PDP-11使用中断优先级;CPU的工作状态--管态还是目态,用来说明当前在CPU上执行的是操作系统还是一般用户,从而决定其是否可以使用特权指令或拥有其它的特殊权力。

2.11 CPU如何发现中断事件?发现中断事件后应做什么工作?答:处理器的控制部件中增设一个能检测中断的机构,称为中断扫描机构。

通常在每条指令执行周期内的最后时刻中扫描中断寄存器,询为是否有中断信号到来。

若无中断信号,就继续执行下一条指令。

若有中断到来,则中断硬件将该中断触发器内容按规定的编码送入程序状态字PSW的相应位(IBM-PC中是第16~31位),称为中断码。

发现中断事件后应执行相中断处理程序,先由硬件进行如下操作:1、将处理器的程序状态字PSW压入堆栈2、将指令指针IP(相当于程序代码段落的段内相对地址)和程序代码段基地址寄存器CS的内容压入堆栈,以保存被子中断程序的返回地址。

3、取来被接受的中断请求的中断向量地址(其中包含有中断处理程序的IP,CS的内容),以便转入中断处理程序。

操作系统第九版部分课后作业习题答案分析解析

操作系统第九版部分课后作业习题答案分析解析

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.若处理器有32位地址,则它的虚拟地址空间为( B )字节。

A 2GB B 4GBC 100KBD 640KB2.支持程序浮动的地址转换机制是( A )A 动态重定位B 段式地址转换C 页式地址转换D 静态重定位3.UNIX中的文件系统采用( D )。

A 网状文件B 记录式文件C 索引文件D 流式文件4.段页式管理每取一数据,要访问( C )次内存。

A 1B 2C 3D 45.文件系统的主要目的是( A )。

A 实现对文件的按名存取B 实现虚拟存贮器C 提高外围设备的输入输出速度D 用于存贮系统文档6. 某基于动态分区存储管理的计算机,其主存容量为55mb(初始为空),采用最佳适配算法,分配和释放的顺序为:分配15mb,分配30mb,释放15mb,分配8mb,分配6mb,此时主存中最大空闲分区的大小是( B )A 7mbB 9mbC 10mbD 15mb7.设计批处理多道系统时,首先要考虑的是( B )。

A 灵活性和可适应性B 系统效率和吞吐量C 交互性和响应时间D 实时性和可靠性8.进程调度的对象和任务分别是( C )。

A 作业,从就绪队列中按一定的调度策略选择一个进程占用CPUB 进程,从后备作业队列中按调度策略选择一个作业占用CPUC 进程,从就绪队列中按一定的调度策略选择一个进程占用CPUD 作业,从后备作业队列中调度策略选择一个作业占用CPU9.一种既有利于短小作业又兼顾到长作业的作业调度算法是( C )。

A 先来先服务B 轮转C 最高响应比优先D 均衡调度10.两个进程合作完成任务。

在并发执行中,一个进程要等待其合作伙伴发来消息,或者建立某个条件后再向前执行,这种制约性合作关系称为进程的( B )。

A 互斥B 同步C 调度D 伙伴11.当每类资源只有一个个体时,下列说法中不正确的是(C )。

A 有环必死锁B 死锁必有环C 有环不一定死锁D 被锁者一定全在环中12.在现代操作系统中引入了( D ),从而使并发和共享成为可能。

操作系统习题(附参考答案)

操作系统习题(附参考答案)

操作系统习题(附参考答案)一、单选题(共100题,每题1分,共100分)1、下列存储器中,速度最快的是()。

A、内存B、寄存器C、CacheD、磁盘正确答案:B2、时钟中断事件属于()中断事件。

A、程序B、自愿性C、外部D、输入/输出正确答案:C3、可变分区存储管理系统中,若采用最佳适应分配算法,“空闲区表”中的空闲区可按()顺序排列。

A、大小从大到小B、大小从小到大C、地址从大到小D、地址从小到大正确答案:B4、从静态的角度看,下列选项中哪一个是进程必须拥有而程序所没有的?()A、常量数据B、全局变量C、进程控制块D、代码正文正确答案:C5、()不是管程的组成部分。

A、对局部于管程内的数据结构设置初始值的语句B、对管程内数据结构进行操作的一组过程C、局部于管程的共享数据结构D、管程外过程调用管程内数据结构的说明正确答案:D6、下列关于父进程和子进程的叙述中,正确的是()。

A、子进程执行完了,父进程才能执行B、父进程创建了子进程,因此父进程执行完了,子进程才能执行C、撤销子进程时,应该同时撤销父进程D、撤销父进程时,应该同时撤销子进程正确答案:D7、某计算机系统中有8台打印机,有K个进程竞争使用,每个进程最多需要3台打印机。

该系统可能会发生死锁的K的最小值是()。

A、3B、4C、2D、5正确答案:B8、分页虚拟存储管理系统中,若采用FIFO页面置换算法,则当分配的物理页面数增加时,缺页中断的次数()。

A、减少B、可能增加也可能减少C、增加D、不变正确答案:B9、产生内存抖动的主要原因是()。

A、内存空间太小B、CPU运行速度太慢C、CPU调度算法不合理D、页面置换算法不合理正确答案:D10、()存储管理兼顾了段式在逻辑上清晰和页式在存储管理上方便的优点。

A、分页B、段页式C、可变分区D、分段正确答案:B11、发生死锁的必要条件有四个,要预防死锁的发生,可以破坏这四个必要条件,但破坏()条件是不太实际的。

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

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

操作系统习题与解答(含答案)第⼀章操作系统引论⼀、选择题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.订购机票系统处理各⾃各个终端的服务请求,处理后通过终端回答⽤户,所以它是⼀个()。

windows操作系统练习题及答案

windows操作系统练习题及答案

windows操作系统练习题及答案一、选择题1、在 Windows 操作系统中,以下哪个组合键可以用于切换不同的应用程序窗口?()A Alt + TabB Ctrl + Alt + DelC Ctrl + ShiftD Windows 键+ R答案:A解释:在 Windows 操作系统中,使用 Alt + Tab 组合键可以方便地在打开的应用程序窗口之间进行切换。

2、在 Windows 操作系统中,要删除一个文件,以下哪种操作是错误的?()A 选中文件后按下 Delete 键B 将文件拖到回收站C 选中文件后,在文件菜单中选择“删除”命令D 直接关闭包含该文件的窗口答案:D解释:直接关闭包含文件的窗口并不能删除文件。

而通过按下Delete 键、将文件拖到回收站或者在文件菜单中选择“删除”命令,都可以将文件放入回收站。

3、 Windows 操作系统中的“任务管理器”可以用来查看以下哪些信息?()A 运行的程序和进程B 系统性能C 网络状态D 以上都是答案:D解释:Windows 任务管理器能够提供有关运行的程序和进程、系统性能(如 CPU 使用率、内存使用情况等)以及网络状态等多种信息。

4、在 Windows 中,以下哪个不是合法的文件名?()A filetxtB my filedocC 123txtD abctxt答案:D解释:文件名中不能包含某些特殊字符,如、?、"、<、>、|等。

5、要在 Windows 中查找某个文件,以下哪种方法不正确?()A 在资源管理器中使用搜索功能B 在开始菜单中选择“搜索”命令C 在桌面上按 F3 键D 逐个打开文件夹查找答案:D解释:逐个打开文件夹查找效率低下,而前三种方法都可以利用系统提供的搜索功能更快捷地找到所需文件。

二、填空题1、 Windows 操作系统的桌面主要由(图标)、(任务栏)等组成。

2、在 Windows 中,复制文件的快捷键是( Ctrl + C ),粘贴文件的快捷键是( Ctrl + V )。

操作系统作业答案

操作系统作业答案

《操作系统》同步练习第一章操作系统引论一、填空题1、操作系统向用户提供了三种接口,分别是:命令接口、程序接口、图形接口。

2、可以从不同的角度来观察OS。

从一般用户的观点,可把OS看作是用户与计算机硬件系统之间的接口;从资源管理观点上看,则可以把OS视为计算机系统资源的管理者。

3、计算机系统中的软硬件资源可以分为四类,分别是:。

4、当前三大种类操作系统分别是:并发、共享、虚拟。

5、多道批处理操作系统的特征是:多道性,无序性,调度性。

6、分时操作系统的特征是:多路性,独立性,及时性,交互性。

7、操作系统的四大特征分别是:并发、共享、虚拟、异步。

最基本的特征是并发。

二、名词解释操作系统:是配置在计算机硬件上的第一层软件,是对硬件系统的首次扩充.脱机IO技术:联机IO技术:多道批处理操作系统:是一种有效但又十分复杂的系统实时操作系统:是指系统能及时(或即时)响应外部事件的请求,在规定时间内完成对该事件的处理,并控制所有实时任务协调.分时操作系统:是为了满足用户需求所形成的一种新型OS.进程:是以异步方式运行的.并以人们不可预知的速度向前推进的.并发:是指两个或多个事件在同一时间间隔内发生.并行:是指两个或多个事件在同一时刻发生.互斥共享:虚拟:是指通过某种技术把一个物理实体变为若干个逻辑上的对应物.作业调度:是从后备队列中按照一定的算法选择出若干个作业,为它们分配其必需的资源.进程调度:是从进程的就绪队列中选出一新进程,把处理机分配给它,并为它设置运行现场,使进程投入执行.三、问答题1、操作系统的主要任务是什么?答:是为多道程序的运行提供良好的运行环境,以保证多道程序能有条不紊地,高效地运行,并能最大程度地提高系统中各种资源的利用率和方便用户的使用.操作系统主要具有哪几方面功能?答:有处理机管理,存储器管理,设备管理和文件管理.2、处理机管理有那些主要功能?答:是创建和撤消进程(线程),对诸进程(线程)的运行进行协调,实现进程(线程)之间的信息交换,以及按照一定的算法把处理机分配给进程(线程)它们的主要任务是什么?答:进程控制,进程同步,进程通信及调度3、内存管理有那些主要功能?答:内存分配,内存保护,XXX映射,内存扩充它们的主要任务是什么?答: 是为多道程序的运行提供良好的环境,方便用户使用存储器,提高存储器的利用率以及能从逻辑上扩充内存.4、设备管理有那些主要功能?答:具有缓冲管理,设备分配和设备处理以及虚拟设备等功能它们的主要任务是什么?答:完成用户进程提出的I/O请求,为用户进程分配其所需的I/O设备,提高CPU和I/O设备的利用率,提高I/O速度,方便用户使用I/O设备.5、文件管理有那些主要功能?答:具有对文件存储空间的管理,目录管理,文件的读/写管理以及文件的共享与保护等功能.它们的主要任务是什么?答:是对用户文件和系统文件进行管理,以方便用户使用,并保证文件的安全性.6、简要说明操作系统的四大特征。

操作系统习题带附标准答案

操作系统习题带附标准答案

操作系统习题带附标准答案第五章⼀、问答题1、简述页式虚拟存储管理的基本原理。

2、交换扩充了内存,因此,交换也实现了虚拟存储器。

这句话对吗?不对。

交换是把各个进程完整地调⼊内存,运⾏⼀段时间,再放回磁盘上。

虚拟存储器是使进程在只有⼀部分在内存的情况下也能运⾏。

交换是把整个进程换⼊换出主存。

⽽虚拟存储器的基本思想是程序的⼤⼩可以超过物理内存的⼤⼩,操作系统把程序的⼀部分调⼊主存来运⾏,⽽把其他部分保留在磁盘上。

故交换并未实现虚拟存储器。

3、简述虚拟存储器的实现原理。

4、简述快表的作⽤。

5、什么是紧凑?什么时候紧凑?6、⽐较存储管理中的连续分配和离散分配⽅式。

7、当系统中的地址空间⾮常⼤时(例如32位),会给页表的设计带来什么问题?请给出⼀个⽅案并分析其优缺点。

答:会导致页表过长从⽽很难找到⼀块连续的存储空间存放页表,此外如果页表中的⾏不连续也会加⼤访问页表的查找时间。

可以⽤多级页表解决这个问题,将页表分页,离散地存储在不同区域,同时建⽴另⼀张页表映射原来页表的每⼀页。

优点是不需要⼤块的连续空间,但并没有减少页表的空间,同时也增加了访存次数。

8、缺页中断和⼀般中断有什么区别?9、简述分页存储管理的基本思想和页表的作⽤。

10、交换扩充了内存,因此,交换也实现了虚拟存储器。

这句话对吗?11、叙述简单Clock置换算法的实现⽅案。

12、解释静态重定位与动态重定位。

13、什么叫紧凑,什么时候紧凑?14、为了实现虚拟页式存储管理,页表应该包含哪些内容?15、页和段有哪些区别?16、覆盖技术和交换技术的特点是什么?17、简述分页和分段的区别。

18、什么是紧凑?什么时候紧凑?19、简述虚拟存储器的定义。

20、简述分页和分段的区别21什么叫可重⼊代码?22、局部性原理可以体现在哪两个⽅⾯,其具体含义是什么?23、分页和分段的主要区别是什么?⼆、计算题1、现有⼀分页虚拟存取管理系统,其页表保存在寄存器中。

若有⼀个可⽤的空页或被替换的页未被修改,则它处理⼀个缺页中断需要8ms。

操作系统部分习题参考答案(孙钟秀版)

操作系统部分习题参考答案(孙钟秀版)

操作系统部分习题参考答案(孙钟秀版)操作系统部分习题参考答案第⼀章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有等待时间段为180ms⾄200ms间(见图中有⾊部分)。

5. 在单CPU和两台I/O(I1,I2)设备的多道程序设计环境下,同时投⼊三个作业运⾏。

它们的执⾏轨迹如下:Job1:I2(30ms)、CPU(10ms)、I1(30ms)、CPU(10ms)Job2:I1(20ms)、CPU(20ms)、I2(40ms)Job3:CPU(30ms)、I1(20ms)如果CPU、I1和I2都能并⾏⼯作,优先级从⾼到低为Job1、Job2和Job3,优先级⾼的作业可以抢占优先级低的作业的CPU。

试求:(1)每个作业从投⼊到完成分别所需的时间。

(2) 从作业的投⼊到完成CPU的利⽤率。

(3)I/O设备利⽤率。

答:画出三个作业并⾏⼯作图如下(图中着⾊部分为作业等待时间):(1) Job1从投⼊到运⾏完成需80ms,Job2从投⼊到运⾏完成需90ms,Job3从投⼊到运⾏完成需90ms。

(2) CPU空闲时间段为:60ms⾄70ms,80ms⾄90ms。

所以CPU利⽤率为(90-20)/80=77.78%。

(3) 设备I1空闲时间段为:20ms⾄40ms,故I1的利⽤率为(90-20)/90=77.78%。

大工19春《操作系统》在线作业123参考答案

大工19春《操作系统》在线作业123参考答案

大工19春《操作系统》在线作业123参考答案大工19春《操作系统》在线作业1以下软件系统中完全属于系统软件的一组是()。

A.操作系统、Windows7C.Excel2010、编译系统D.WindowsXP、腾讯QQ正确答案:A引入多道程序的目的在于()。

A.充分利用CPU,减少CPU的等待时间B.提高实时响应速度,降低CPU及内存利用率C.有利于代码共享,减少主存辅存信息交换量D.充分利用主存储器正确答案:A多道批处理系统(多道程序设计技术)的硬件支持是20世纪60年代初发展起来的()。

A.RISC技术B.通道和中断技术C.集成电路D.高速内存正确答案:B假定分时操作体系的时间片固定,那末(),则相应时间越长。

A.用户数越少B.用户数越多C.内存越少D.内存越多正确答案:B过程掌握体系、信息查询体系等均属于实时体系,那末实时体系()。

A.是依赖人为干预的监督和控制系统B.必须既要及时响应、快速处理,又要有高可靠性和安全性C.强调系统资源的利用率D.本色上是批处理体系和分时体系的结合精确答案:B操作系统是计算机系统中不可缺少的组成部分,是为了提高计算机的()和方便用户使用计算机而配备的一种系统软件。

A.网络接入方式B.利用率C.软件更新速度D.硬件更新速度正确答案:B核心态下运转的程序可以执行特权指令,其中特权指令是指()。

A.只能被操作系统使用的指令B.既允许操作系统程序使用,又允许用户程序使用C.是管态和目态运转的根本单元D.是一种存储保护方法正确答案:A当CPU执行操作系统程序时,处理器处于()。

A.目态B.管态C.用户态D.准备就绪态正确答案:B当用户程序执行访管指令(如申请内存)时,中断装置将使中央处理器()工作。

A.维持在管态B.坚持在目态C.从目态转换到管态D.从管态转换到目态精确答案:C中断向量存放()。

A.中断处理程序入口地址B.中断向量表出口地址C.中断断点地址D.中断返回地址精确答案:A用户可以为每个进程创建PCB,并控制进程的执行过程。

操作系统第九版部分课后作业习题答案

操作系统第九版部分课后作业习题答案

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 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 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 Why 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 initialc ontiguous 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 moreefficie ntly 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 number or 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:Dynamic tables allow more flexibility in system use growth — tablesare never exceeded, avoiding artificial 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 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 ta rget file system at the VFS layer. The calling program has no file-system-specific code, and the upper levels of the system call structures likewise are file system-independent. The translation at the VFS layer turns these generic calls into file-system-specific operations.。

操作系统作业答案

操作系统作业答案

操作系统作业(第一章—第四章)一、单项选择1 在计算机系统中配置操作系统的目的是【】。

A 增强计算机系统的功能B 提高系统资源的利用率C 合理组织工作流程以提高系统吞吐量D 提高系统的运行速度2 在操作系统中采用多道程序设计技术,能有效提高CPU、内存和I/O设备的【】。

A 灵活性B 可靠性C 兼容性D 利用率3 在操作系统中,并发性是指若干事件【】发生。

A 在同一时刻B 一定不在同一时刻C 在某一时间间隔内D 依次在不同时间间隔内4 以下不属于衡量操作系统性能指标的是【】。

A 作业的大小B 资源利用率C 吞吐量D 周转时间5 下列选项中,操作系统提供给应用程序的接口是【】。

A 系统调用B 中断C 函数D 原语6 在分时系统中,当用户数为50时,为了保证响应时间不超过1s,选取的时间片最大值为【】。

A 10msB 20msC 50msD 100ms7 假设就绪队列中有10个就绪进程,以时间片轮转方式进行进程调度,如果时间片为180ms,切换开销为20ms。

如果将就绪进程增加到30个,则系统开销所占的比率为【】。

A 10%B 20%C 30%D 90%8 中断系统一般由相应的【】组成。

A 硬件B 软件C 硬件和软件D 固件9 以下工作中,【】不是创建进程所必须的。

A 创建进程的PCB B 为进程分配内存C 为进程分配CPUD 将PCB插入就绪队列10 系统中有5个用户进程且CPU工作于用户态,则处于就绪状态或阻塞状态的进程数最多分别为【】。

A 5,4B 4,0C 0,5D 4,511 如果系统中有n个进程,则就绪队列中进程的个数最多为【】。

A 1B n-1C nD n+112 一次I/O操作的结束,有可能导致一个或几个进程【】。

A 由阻塞变为就绪B 由运行变为就绪C 由阻塞变为运行D 由就绪变为运行13 某个运行中的进程要申请打印机,则它的状态变为【】。

A 就绪B 阻塞C 创建D 挂起14 【】必然会引起进程切换。

操作系统作业(1-4)答案

操作系统作业(1-4)答案

操作系统作业(第一章—第四章)一、单项选择1 在计算机系统中配置操作系统的目的是【】。

A 增强计算机系统的功能B 提高系统资源的利用率C 合理组织工作流程以提高系统吞吐量D 提高系统的运行速度2 在操作系统中采用多道程序设计技术,能有效提高CPU、内存和I/O设备的【】。

A 灵活性B 可靠性C 兼容性D 利用率3 在操作系统中,并发性是指若干事件【】发生。

A 在同一时刻B 一定不在同一时刻C 在某一时间间隔内D 依次在不同时间间隔内4 以下不属于衡量操作系统性能指标的是【】。

A 作业的大小B 资源利用率C 吞吐量D 周转时间5 下列选项中,操作系统提供给应用程序的接口是【】。

A 系统调用B 中断C 函数D 原语6 在分时系统中,当用户数为50时,为了保证响应时间不超过1s,选取的时间片最大值为【】。

A 10msB 20msC 50msD 100ms7 假设就绪队列中有10个就绪进程,以时间片轮转方式进行进程调度,如果时间片为180ms,切换开销为20ms。

如果将就绪进程增加到30个,则系统开销所占的比率为【】。

A 10%B 20%C 30%D 90%8 中断系统一般由相应的【】组成。

A 硬件B 软件C 硬件和软件D 固件9 以下工作中,【】不是创建进程所必须的。

A 创建进程的PCB B 为进程分配内存C 为进程分配CPUD 将PCB插入就绪队列10 系统中有5个用户进程且CPU工作于用户态,则处于就绪状态或阻塞状态的进程数最多分别为【】。

A 5,4B 4,0C 0,5D 4,511 如果系统中有n个进程,则就绪队列中进程的个数最多为【】。

A 1B n-1C nD n+112 一次I/O操作的结束,有可能导致一个或几个进程【】。

A 由阻塞变为就绪B 由运行变为就绪C 由阻塞变为运行D 由就绪变为运行13 某个运行中的进程要申请打印机,则它的状态变为【】。

A 就绪B 阻塞C 创建D 挂起14 【】必然会引起进程切换。

《操作系统》作业及参考答案

《操作系统》作业及参考答案

《操作系统》作业及参考答案第1章操作系统概述1.3.1选择最合适的答案1.一般用户更喜欢使用的系统是()。

A.手工操作B.单道批处理C.多道批处理D.多用户分时系统2. 与计算机硬件关系最密切的软件是()。

A.编译程序B.数据库管理系统C.游戏程序D.OS3. 现代OS具有并发性和共享性,是()的引入导致的。

A.单道程序B. 磁盘C. 对象D.多道程序4. 早期的OS主要追求的是()。

A.系统的效率B.用户的方便性C.可移植D.可扩充性5.()不是多道程序系统A.单用户单任务B.多道批处理系统C.单用户多任务D.多用户分时系统6.()是多道操作系统不可缺少的硬件支持。

A.打印机B.中断机构C.软盘D.鼠标7. 特权指令可以在()执行。

A.目态B.浏览器中C.任意的时间D.进程调度中8. 没有了()计算机系统就启动不起来。

A.编译器B.DBMSC.OSD.浏览器9. 通道能够完成()之间的数据传输。

A.CPU与外设B.内存与外设C.CPU与主存D.外设与外设10. 操作系统的主要功能有()。

A.进程管理、存储器管理、设备管理、处理机管理B.虚拟存储管理、处理机管理、进程调度、文件系统C.处理机管理、存储器管理、设备管理、文件系统D.进程管理、中断管理、设备管理、文件系统11. 单处理机计算机系统中,()是并行操作的。

A.处理机的操作与通道的操作是并行的B.程序与程序C.主程序与子程序D.用户程序与操作系统程序12. 处理机的所有指令可以在()执行。

A.目态B.浏览器中C.任意的时间D.系统态13.()功能不是操作系统直接完成的功能。

A.管理计算机硬盘B.对程序进行编译C.实现虚拟存储器D.删除文件14. 要求在规定的时间内对外界的请求必须给予及时响应的OS是()。

A.多用户分时系统B.实时系统C.批处理系统时间D.网络操作系统15. 操作系统是对()进行管理的软件。

A.硬件B.软件C.计算机资源D.应用程序16.()对多用户分时系统最重要。

操作系统 第三章部分答案

操作系统 第三章部分答案

操作系统第三章的作业书本110页7.设单处理器系统中有 5个进程P1、P2、P3、P4、P5并发执行,其运行时间分别为10、1、2、1、5,优先权分别为3、1、3、4、2,这些进程几乎同时到达,在就绪队列中的次序依次为P1、P2、P3、P4、P5,试计算采用时间片轮转(时间片为2),短进程优先、非抢占式优先权算法进行调度时的平均周转时间和平均等待时间。

解:(1)时间片轮转调度算法,时间片大小为2min采用时间片轮转调度算法进行调度时的平均周转时间为9.6 min,平均带权周转时间为 3.28 min,平均等待时间为 5.8 min。

(2)短进程优先调度算法采用短进程优先调度算法进行调度时的的平均周转时间为 7 min,平均带权周转时间为 1.74 min,平均等待时间为 3.2 min。

(3.1)非抢占式优先权算法(假设值越大,优先级越高)采用非抢占式优先权算法(假设值越大,优先级越高)进行调度时的的平均周转时间为 12.4 min,平均带权周转时间为 6.24 min,平均等待时间为 8.6 min。

(3.2)非抢占式优先权算法(假设值越小,优先级越高)采用非抢占式优先权算法(假设值越小,优先级越高)进行调度时的的平均周转时间为 12 min,平均带权周转时间为 6.36 min,平均等待时间为 8.2 min。

8.有4个作业J1、J2、J3、J4,它们达到的时间分别为9:00、9:40、9:50、10:10,所需的CPU时间分别为70min、30min、10min、5min,分别采用先来先服务调度算法和短作业优先调度算法进行调度,试问它们的调度顺序、作业的周转时间和平均周转时间各是多少?解:(1)先来先服务调度算法(2)短作业优先调度算法9.一个能容纳两道作业的批处理系统,作业调度采用短作业优先调度算法,进程调度采用抢占式优先权算法。

表3-11列出了先后到达的几个作业的相关时间和优先级(值越小,优先级越高),试计算:①各作业进入内存的时间和完成时间;②平均周转时间。

操作系统部分课后习题答案

操作系统部分课后习题答案

操作系统部分课后习题答案第一章1、设计现代OS的主要目标就是什么?便利性,有效性,可扩充性与开放性。

2、OS的作用可表现在哪几个方面?(1)OS作为用户与计算机硬件系统之间的接口。

(2)OS作为计算机系统资源的管理者。

(3)OS实现了对计算机资源的抽象。

4、试说明推进多道批处理系统形成与进展的主要动力就是什么主要动力来源于四个方面的社会需求与技术进展(1)不断提高计算机资源的利用率(2)便利用户(3)器件的不断更新换代(4)计算机体系结构的不断进展。

7、实现分时系统的关键问题就是什么?应如何解决关键问题就是当用户在自己的终端上键入命令时,系统应能准时接收并准时处理该命令。

在用户能接受的时延内将结果返回给用户。

解决办法:针对准时接收问题,可以在系统中设置多路卡,使主机能同时接收用户从各个终端上输入的数据,为每个终端配置缓冲区,暂存用户键入的命令或数据。

针对准时处理问题,应使全部的用户作业都直接进入内存,并且为每个作业分配一个时光片,允许作业只在自己的时光片内运行。

这样在不长的时光内,能使每个作业都运行一次。

12、试从交互性、准时性以及牢靠性方面,将分时系统与实时系统举行比较。

(1)准时性。

实时信息处理系统对实时性的要求与分时系统类似,都就是以人所能接受的等待时光来确定,而实时控制系统的准时性,就是以控制对象所要求的开头截止时光或完成截止时光来确定的,普通为秒级到毫秒级,甚至有的要低于100微妙。

(2)交互性。

实时信息处理系统具有交互性,但人与系统的交互仅限于拜访系统中某些特定的专用服务程序,不像分时系统那样能向终端用户提供数据与资源分享等服务。

(3)牢靠性。

分时系统也要求系统牢靠,但相比之下,实时系统则要求系统具有高度的牢靠性。

由于任何差错都可能带来巨大的经济损失,甚至就是灾害性后果,所以在实时系统中,往往都实行了多级容错措施保障系统的平安性及数据的平安性。

13、OS有哪几大特征?其最基本的特征就是什么?并发性、分享性、虚拟性与异步性四个基本特征。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
DataCollection:
begin
repeat
……
gatherdatainnextp;
wait(empty);
wait(mutex);
buffer:=nextp;
signal(mutex);
signal(full);
untilfalse;
end
DataCompute:
begin
repeat
Байду номын сангаас……
第二章进程管理
作业3.在测量控制系统中的数据采集任务DataCollection()时,把所有采集的数据送到一个单缓冲区,计算任务DataCompute()从该缓冲区取出数据进行计算。试写出利用信号量机制实现两任务共享缓冲区Buffer的同步算法。
方法一:
Varmutex,empty,full:semaphore:=1,1,0;
进程/资源
Allocation
Need
Available
ABC
ABC
ABC
P0
P1
P2
P3
P4
021
101
013
321
020
410
231
404
422
513
352
问:(1)该状态是否安全,如果不安全说明理由,如果安全给出安全序列;
安全序列是:P1,P0,P2,P3,P4
(2)若进程P3提出请求Request(1,2,1)后,系统是否安全,如果不安全说明理由,如果安全给出分配后的安全序列。
repeat
……
gatherdatainnextp;
wait(empty);
buffer:=nextp;
signal(full);
untilfalse;
end
DataCompute:
begin
repeat
……
wait(full);
nextc:=buffer;
signal(empty);
computedatainnextc;
3)采用最近最久未使用LRU置换算法,计算访问过程中所发生的缺页次数和缺页率。
4
3
2
1
4
3
5
4
3
2
1
5
6
2
3
7
1
2
6
1
4
3
2
1
4
3
5
4
3
2
1
5
6
2
3
7
1
2
6
1
4
3
2
1
4
3
5
4
3
2
1
5
6
2
3
7
1
2
6
4
3
2
1
4
3
5
4
3
2
1
5
6
2
3
7
1
2
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
缺页率:17/20=85%
16
16
8
32
64
32
8
16
64
1)首次适应算法
A7*
C9*
F8*
8
8
B18*
14
D20*
E35*
9
32
8
16
64
2)循环首次适应算法
A,F,1
16
8
B,14
C,55
D,12
8
16
E,29
3)最佳适应算法
16
16
A7*
1
B18*
C9*
5
E35*
29
D20*
12
F8*
16
64
4)最坏适应算法
16
16
8
6
1
4
3
2
1
4
3
5
2
1
6
3
7
1
2
6
4
3
2
1
4
3
5
2
1
6
3
7
1
2
4
3
2
1
4
3
5
2
1
6
3
7
1
缺页率:15/20=75%
2)采用最佳页面Optimal置换算法,计算访问过程中所发生的缺页次数和缺页率;
4
3
2
1
4
3
5
4
3
2
1
5
6
2
3
7
1
2
6
1
4
4
4
4
4
2
2
2
2
2
6
3
3
3
3
3
1
1
1
1
1
2
1
5
5
5
6
3
7
7
缺页率:11/20=55%
F,24
A,C,D,28
32
8
16
B,E,11
“*”表示已分配
2.假设物理块数M=3,有一个作业的页面走向为
4、3、2、1、4、3、5、4、3、2、1、5、6、2、3、7、1、2、6、1
1)采用先进先出FIFO页面置换算法,计算访问过程中所发生的缺页次数和缺页率;
4
3
2
1
4
3
5
4
3
2
1
5
6
2
3
7
1
2
wait(full);
wait(mutex);
nextc:=buffer;
signal(mutex);
signal(empty);
computedatainnextc;
untilfalse;
end
方法二:
Varempty,full:semaphore:=1,0;
DataCollection:
begin
假设P3的请求Request(1,2,1)得到满足,即:
进程/资源
Allocation
Need
Available
ABC
ABC
ABC
P0
P1
P2
P3
P4
021
101
013
442
020
410
231
404
301
513
231
安全序列是:P1,P3,P0,P2,P4
1.假设有一批作业A、B、C、D、E、F,它们的大小分别为A:7KB、B:18KB、C:9KB、D:20KB、E:35KB、F:8KB,根据不同的算法把它们分配到如下空闲分区表中。
begin
repeat
……
wait(mutex);
nextc:=buffer;
signal(mutex);
computedatainnextc;
untilfalse;
end
答:如果有多个DataCollection和多个DataCompute,则可能会出现多个同类进程依次操作同一数据的情况,这种情况通常是不允许的。比如,多个DataCollection依次生产了多个data,只有最后一个数据得以保留。
算法
进程名
A
B
C
D
E
平均
到达时间
0
1
3
4
6
服务时间
5
7
3
8
2
FCFS
完成时间
5
12
15
23
25
周转时间
5
11
12
19
19
带权周转时间
1
11/7
4
19/8
19/2
SJF
完成时间
5
17
8
25
10
周转时间
5
16
5
21
4
带权周转时间
1
16/7
5/3
21/8
2
2.用时间片轮转法RR调度进程A、B、C、D和E,时间片q分别为2和4,完成下面的表格(参考教材P96图3-6)。
untilfalse;
end
如下的方法三有问题吗?
Varmutex:semaphore:=1;
DataCollection:
begin
repeat
……
gatherdatainnextp;
wait(mutex);
buffer:=nextp;
signal(mutex);
untilfalse;
end
DataCompute:
算法
进程名
A
B
C
D
E
平均
到达时间
0
1
2
3
4
服务时间
6
2
5
9
8
RR
q=2
完成时间
16
4
21
28
30
周转时间
16
3
19
25
26
带权周转时间
8/3
1.5
3.8
25/9
3.25
RR
q=4
完成时间
22
6
11
26
30
周转时间
22
5
9
23
26
带权周转时间
相关文档
最新文档