操作系统部分作业参考答案
操作系统作业(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. 什么是操作系统?操作系统是计算机系统的一个重要组成部分,它是一种管理计算机硬件和软件资源的系统软件,为用户提供一个操作计算机的环境。
2. 操作系统的主要功能是什么?操作系统的主要功能包括进程管理、文件管理、内存管理、设备管理和网络管理。
3. 进程是指什么?进程是指计算机中正在执行的程序的实例。
每个进程都有自己的内存空间、寄存器和其他系统资源,它们可以并行或交替执行。
4. 什么是进程调度算法?进程调度算法是操作系统使用的一种策略,用于决定哪个进程应当被调度并占用处理器资源。
常见的调度算法有先来先服务、短作业优先、轮转法等。
5. 文件系统是什么?文件系统是操作系统管理计算机存储设备上文件的一种方式,它可以对文件进行存储、组织、管理和访问。
第二部分:简答题1. 请简要解释操作系统的内存管理功能。
操作系统的内存管理功能包括内存分配、内存保护和内存回收。
内存分配是指根据程序的需要,将可用的内存分配给进程;内存保护是指防止一个进程越界访问其他进程或操作系统的内存;内存回收是指当一个进程退出或者不再需要内存时,将其所占用的内存释放出来,以便其他进程使用。
2. 请简要解释死锁是什么,以及如何避免死锁?死锁是指两个或多个进程因为互相等待对方所持有的资源而无法继续执行的状态。
为避免死锁,可以采取以下措施:破坏死锁产生的四个必要条件(互斥条件、请求与保持条件、不剥夺条件、循环等待条件)之一;使用资源分级、资源有序性等算法进行资源分配;按照固定的顺序申请和释放资源,避免循环等待。
3. 请简要解释虚拟内存的概念及其作用。
虚拟内存是一种操作系统的内存管理技术,它可以将物理内存和磁盘的空间组合起来,提供给进程使用。
虚拟内存的作用是扩大了进程的可用地址空间,允许大于实际物理内存的程序运行;并且能够将不常用的数据或程序部分保存到磁盘上,从而释放出物理内存供其他进程使用。
国家开放大学《操作系统》形考任务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系统简介一、思考题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的内容),以便转入中断处理程序。
操作系统作业一及答案

第一章:操作系统引论1.什么是操作系统?可以从哪些角度阐述操作系统的作用?答:操作系统是计算机系统中的一个系统软件,是能有效地组织和管理计算机系统中的硬件和软件资源,合理地组织计算机工作流程,控制程序的执行,并向用户提供各种服务功能,使得用户能够灵活、方便、有效地使用计算机,并使整个计算机系统能高效地运行的一组程序模块的集合。
作用:控制管理计算机的全部硬软件资源,合理组织计算机内部各部件协调工作,为用户提供操作和编辑界面的程序集合。
2、简要叙述批处理操作系统、分时操作系统和实时操作系统的概念及特点。
答:批处理操作系统:通常是把一批作业以脱机方式输入到磁带(磁盘)上,并在系统中配上监督程序(Monitor),在它的控制下使这批作业能一个接一个地连续处理,直到磁带(磁盘)上所有的作业全部完成。
其特点:(1)自动性;(2)顺序性。
分时操作系统:是指在一台主机上连接多个带有显示器和键盘的终端,同时允许多个用户通过自己的终端,以交互方式使用计算机,共享主机中的资源。
其特点:(1)多路性;(2)独立性;(3)及时性;(4)交互性。
实时操作系统:是指系统及时(或即时)响应外部事件的请求,在规定的时间内完成对该事件的处理,并控制所有实时任务协调一致地运行。
其特点:(1)多路性;(2)独立性;(3)及时性;(4)交互性;(5)可靠性。
3操作系统需要管理哪些资源?它的基本功能是什么?答:硬件资源:CPU,打印机等,软件资源:数据,程序等4操作系统对外提供了哪些接口?答:(1)操作系统的命令接口通过在用户和操作系统之间提供高级通信来控制程序运行,用户通过输入设备发出一系列命令告诉操作系统执行所需功能,它包括了键盘操作命令和作业控制命令,称为作业一级的用户接口。
命令接口的两种最普遍和主要的方式是直接命令方式(命令行)和间接命令方式(命令文件)。
(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.若处理器有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 ),从而使并发和共享成为可能。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
第二章进程管理
作业3. 在测量控制系统中的数据采集任务DataCollection()时,把所有采集的数据送到一个单缓冲区,计算任务DataCompute()从该缓冲区取出数据进行计算。
试写出利用信号量机制实现两任务共享缓冲区Buffer的同步算法。
方法二:
答:如果有多个DataCollection和多个DataCompute,则可能会出现多个同类进程依次操作同一数据的情况,这种情况通常是不允许的。
比如,多个DataCollection依次生产了多个data,只有最后一个数据得以保留。
2. 用时间片轮转法RR调度进程A、B、C、D和E,时间片q分别为2和4,
问:(1)该状态是否安全,如果不安全说明理由,如果安全给出安全序列;
安全序列是:P1,P0,P2,P3,P4
(2)若进程P3提出请求Request(1,2,1)后,系统是否安全,如果不安全说明理由,如果安全给出分配后的安全序列。
安全序列是:P1,P3,P0,P2,P4
1. 假设有一批作业A、B、C、D、E、F,它们的大小分别为A:7KB、B:18KB、C:9KB、D:20KB、E:35KB、F:8KB,根据不同的算法把它们分配到如下空闲分区表中。
“*”表示已分配
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页面置换算法,计算访问过程中所发生的缺页次数和
2)采用最佳页面Optimal置换算法,计算访问过程中所发生的缺页次数和缺
缺页率:11/20=55%
3)采用最近最久未使用LRU置换算法,计算访问过程中所发生的缺页次数。