计算机操作系统教程--核心与设计原理习题9答案

合集下载

操作系统课后习题精选答案

操作系统课后习题精选答案

操作系统课后习题精选答案操作系统作为计算机科学的基础知识之一,是每个计算机专业学生必须掌握的内容。

课后习题的作用是提供课程内容的深度和拓展,以便帮助学生更好地理解和应用所学知识。

以下是我根据自己的学习经验,总结出的操作系统课后习题精选答案。

这些答案涵盖了操作系统中的主要概念和核心原理,对于加深对操作系统的理解有很大的帮助。

1. 什么是操作系统?答案:操作系统是一组程序,它们管理和控制计算机的各种硬件和软件资源,以便于应用程序进行交互式和高效的执行。

操作系统的主要功能包括进程管理、内存管理、磁盘管理、文件管理和网络管理等。

2. 什么是进程?答案:进程是指计算机系统中正在执行的程序的实例。

一个进程可以包含一个或多个线程,并且每个进程都有自己的地址空间、各种资源和状态信息等。

操作系统通过进程管理来协调和控制多个进程的执行,以提供对计算机资源的合理和优化的利用。

3. 什么是线程?答案:线程是进程中的一个独立执行单元,它可以在进程的上下文中运行,并与其他线程共享进程的资源和状态信息等。

线程和进程之间的区别在于,进程是资源分配的基本单位,而线程是操作系统中的调度基本单位。

操作系统利用线程进行并行计算和流程处理,以便快速实现多任务处理和高效运行。

4. 什么是虚拟内存?答案:虚拟内存是操作系统提供的一种机制,用于将计算机的物理内存和应用程序的逻辑地址空间进行映射和管理。

虚拟内存的基本思想是将进程的地址空间分为若干个物理和逻辑区域,并在需要时将这些区域进行映射和替换。

这样,操作系统可以允许应用程序访问超过物理内存容量的数据,从而提高系统的内存利用率和应用程序的执行效率。

5. 什么是文件系统?答案:文件系统是一种操作系统提供的数据存储和管理机制,用于将数据组织为文件、目录和子目录等形式,并提供对文件系统中的不同组成部分进行访问、传输和维护等操作。

文件系统的主要目的是让应用程序可以访问和共享系统中的数据资源,从而有效管理和利用计算机的存储资源。

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

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

CHAPTER 9 Virtual Memory Practice Exercises9.1 Under what circumstances do page faults occur? Describe the actions taken by the operating system when a page fault occurs.Answer:A page fault occurs when an access to a page that has not beenbrought into main memory takes place. The operating system verifiesthe memory access, aborting the program if it is invalid. If it is valid, a free frame is located and I/O is requested to read the needed page into the free frame. Upon completion of I/O, the process table and page table are updated and the instruction is restarted.9.2 Assume that you have a page-reference string for a process with m frames (initially all empty). The page-reference string has length p;n distinct page numbers occur in it. Answer these questions for any page-replacement algorithms:a. What is a lower bound on the number of page faults?b. What is an upper bound on the number of page faults?Answer:a. nb. p9.3 Consider the page table shown in Figure 9.30 for a system with 12-bit virtual and physical addresses and with 256-byte pages. The list of freepage frames is D, E, F (that is, D is at the head of the list, E is second, and F is last).Convert the following virtual addresses to their equivalent physical addresses in hexadecimal. All numbers are given in hexadecimal. (A dash for a page frame indicates that the page is not in memory.)• 9EF• 1112930 Chapter 9 Virtual Memory• 700• 0FFAnswer:• 9E F - 0E F• 111 - 211• 700 - D00• 0F F - EFF9.4 Consider the following page-replacement algorithms. Rank these algorithms on a five-point scale from “bad” to “perfect” according to their page-fault rate. Separate those algorithms that suffer from Belady’s anomaly from those that do not.a. LRU replacementb. FIFO replacementc. Optimal replacementd. Second-chance replacementAnswer:Rank Algorithm Suffer from Belady’s anomaly1 Optimal no2 LRU no3 Second-chance yes4 FIFO yes9.5 Discuss the hardware support required to support demand paging. Answer:For every memory-access operation, the page table needs to be consulted to check whether the corresponding page is resident or not and whether the program has read or write privileges for accessing the page. These checks have to be performed in hardware. A TLB could serve as a cache and improve the performance of the lookup operation.9.6 An operating system supports a paged virtual memory, using a central processor with a cycle time of 1 microsecond. It costs an additional 1 microsecond to access a page other than the current one. Pages have 1000 words, and the paging device is a drum that rotates at 3000 revolutions per minute and transfers 1 million words per second. The following statistical measurements were obtained from the system:• 1 percent of all instructions executed accessed a page other than the current page.•Of the instructions that accessed another page, 80 percent accesseda page already in memory.Practice Exercises 31•When a new page was required, the replaced page was modified 50 percent of the time.Calculate the effective instruction time on this system, assuming that the system is running one process only and that the processor is idle during drum transfers.Answer:effective access time = 0.99 × (1 sec + 0.008 × (2 sec)+ 0.002 × (10,000 sec + 1,000 sec)+ 0.001 × (10,000 sec + 1,000 sec)= (0.99 + 0.016 + 22.0 + 11.0) sec= 34.0 sec9.7 Consider the two-dimensional array A:int A[][] = new int[100][100];where A[0][0] is at location 200 in a paged memory system with pages of size 200. A small process that manipulates the matrix resides in page 0 (locations 0 to 199). Thus, every instruction fetch will be from page 0. For three page frames, how many page faults are generated bythe following array-initialization loops, using LRU replacement andassuming that page frame 1 contains the process and the other twoare initially empty?a. for (int j = 0; j < 100; j++)for (int i = 0; i < 100; i++)A[i][j] = 0;b. for (int i = 0; i < 100; i++)for (int j = 0; j < 100; j++)A[i][j] = 0;Answer:a. 5,000b. 509.8 Consider the following page reference string:1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 2, 3, 7, 6, 3, 2, 1, 2, 3, 6.How many page faults would occur for the following replacement algorithms, assuming one, two, three, four, five, six, or seven frames? Remember all frames are initially empty, so your first unique pages will all cost one fault each.•LRU replacement• FIFO replacement•Optimal replacement32 Chapter 9 Virtual MemoryAnswer:Number of frames LRU FIFO Optimal1 20 20 202 18 18 153 15 16 114 10 14 85 8 10 76 7 10 77 77 79.9 Suppose that you want to use a paging algorithm that requires a referencebit (such as second-chance replacement or working-set model), butthe hardware does not provide one. Sketch how you could simulate a reference bit even if one were not provided by the hardware, or explain why it is not possible to do so. If it is possible, calculate what the cost would be.Answer:You can use the valid/invalid bit supported in hardware to simulate the reference bit. Initially set the bit to invalid. O n first reference a trap to the operating system is generated. The operating system will set a software bit to 1 and reset the valid/invalid bit to valid.9.10 You have devised a new page-replacement algorithm that you thinkmaybe optimal. In some contorte d test cases, Belady’s anomaly occurs. Is the new algorithm optimal? Explain your answer.Answer:No. An optimal algorithm will not suffer from Belady’s anomaly because —by definition—an optimal algorithm replaces the page that will notbe used for the long est time. Belady’s anomaly occurs when a pagereplacement algorithm evicts a page that will be needed in the immediatefuture. An optimal algorithm would not have selected such a page.9.11 Segmentation is similar to paging but uses variable-sized“pages.”Definetwo segment-replacement algorithms based on FIFO and LRU pagereplacement schemes. Remember that since segments are not the samesize, the segment that is chosen to be replaced may not be big enoughto leave enough consecutive locations for the needed segment. Consider strategies for systems where segments cannot be relocated, and thosefor systems where they can.Answer:a. FIFO. Find the first segment large enough to accommodate the incoming segment. If relocation is not possible and no one segmentis large enough, select a combination of segments whose memoriesare contiguous, which are “closest to the first of the list” andwhich can accommodate the new segment. If relocation is possible, rearrange the memory so that the firstNsegments large enough forthe incoming segment are contiguous in memory. Add any leftover space to the free-space list in both cases.Practice Exercises 33b. LRU. Select the segment that has not been used for the longestperiod of time and that is large enough, adding any leftover spaceto the free space list. If no one segment is large enough, selecta combination of the “oldest” segments that are contiguous inmemory (if relocation is not available) and that are large enough.If relocation is available, rearrange the oldest N segments to be contiguous in memory and replace those with the new segment.9.12 Consider a demand-paged computer system where the degree of multiprogramming is currently fixed at four. The system was recently measured to determine utilization of CPU and the paging disk. The results are one of the following alternatives. For each case, what is happening? Can the degree of multiprogramming be increased to increase the CPU utilization? Is the paging helping?a. CPU utilization 13 percent; disk utilization 97 percentb. CPU utilization 87 percent; disk utilization 3 percentc. CPU utilization 13 percent; disk utilization 3 percentAnswer:a. Thrashing is occurring.b. CPU utilization is sufficiently high to leave things alone, and increase degree of multiprogramming.c. Increase the degree of multiprogramming.9.13 We have an operating system for a machine that uses base and limit registers, but we have modified the 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.什么是操作系统的基本功能?答:操作系统的职能是管理和控制汁算机系统中的所有硬、软件资源,合理地组织计算机工作流程,并为用户提供一个良好的工作环境和友好的接口。

操作系统的基本功能包括:处理机管理、存储管理、设备管理、信息管理(文件系统管理)和用户接口等。

2.什么是批处理、分时和实时系统?各有什么特征?答:批处理系统(batchprocessingsystem):操作员把用户提交的作业分类,把一批作业编成一个作业执行序列,由专门编制的监督程序(monitor)自动依次处理。

其主要特征是:用户脱机使用计算机、成批处理、多道程序运行。

分时系统(timesharingoperationsystem):把处理机的运行时间分成很短的时间片,按时间片轮转的方式,把处理机分配给各进程使用。

其主要特征是:交互性、多用户同时性、独立性。

实时系统(realtimesystem):在被控对象允许时间范围内作出响应。

其主要特征是:对实时信息分析处理速度要比进入系统快、要求安全可靠、资源利用率低。

3.多道程序(multiprogramming)和多重处理(multiprocessing)有何区别?答;多道程序(multiprogramming)是作业之间自动调度执行、共享系统资源,并不是真正地同时执行多个作业;而多重处理(multiprocessing)系统配置多个CPU,能真正同时执行多道程序。

要有效使用多重处理,必须采用多道程序设计技术,而多道程序设计原则上不一定要求多重处理系统的支持。

4.讨论操作系统可以从哪些角度出发,如何把它们统一起来?答:讨论操作系统可以从以下角度出发:(1)操作系统是计算机资源的管理者;(2)操作系统为用户提供使用计算机的界面;(3)用进程管理观点研究操作系统,即围绕进程运行过程来讨论操作系统。

上述这些观点彼此并不矛盾,只不过代表了同一事物(操作系统)站在不同的角度来看待。

每一种观点都有助于理解、分析和设计操作系统。

计算机操作系统第四版课后习题答案

计算机操作系统第四版课后习题答案

《计算机操作系统》课后习题答案注:课本为《计算机操作系统(第四版)》,汤小丹梁红兵哲凤屏汤子瀛编著,西安电子科技大学出版社出版第一章1.设计现代OS的主要目标是什么?答:(1)有效性(2)方便性(3)可扩充性(4)开放性2.OS的作用可表现在哪几个方面?答:(1)OS作为用户与计算机硬件系统之间的接口(2)OS作为计算机系统资源的管理者(3)OS实现了对计算机资源的抽象3.为什么说OS实现了对计算机资源的抽象?答:OS首先在裸机上覆盖一层I/O设备管理软件,实现了对计算机硬件操作的第一层次抽象;在第一层软件上再覆盖文件管理软件,实现了对硬件资源操作的第二层次抽象。

OS 通过在计算机硬件上安装多层系统软件,增强了系统功能,隐藏了对硬件操作的细节,由它们共同实现了对计算机资源的抽象。

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

5.何谓脱机I/O和联机I/O?答:脱机I/O 是指事先将装有用户程序和数据的纸带或卡片装入纸带输入机或卡片机,在外围机的控制下,把纸带或卡片上的数据或程序输入到磁带上。

该方式下的输入输出由外围机控制完成,是在脱离主机的情况下进行的。

而联机I/O方式是指程序和数据的输入输出都是在主机的直接控制下进行的。

6.试说明推动分时系统形成和发展的主要动力是什么?答:推动分时系统形成和发展的主要动力是更好地满足用户的需要。

主要表现在:CPU 的分时使用缩短了作业的平均周转时间;人机交互能力使用户能直接控制自己的作业;主机的共享使多用户能同时使用同一台计算机,独立地处理自己的作业。

7.实现分时系统的关键问题是什么?应如何解决?答:关键问题是当用户在自己的终端上键入命令时,系统应能及时接收并及时处理该命令,在用户能接受的时延内将结果返回给用户。

操作系统教程课后习题答案

操作系统教程课后习题答案

操作系统1.什么是计算机系统?计算机系统是怎么构成的?了解PC的组成情况,说明:1)硬件组织的基本结构,画出硬件配置图;2)主要系统软件和应用软件(若有的话)他们的作用。

答:计算机系统就是按照人的要求接收和存储信息,自动进行数据处理和计算,并输出结果信息的系统。

计算机系统由硬件子系统和软件子系统组成。

计算机系统的构成包括:如图1.2计算机硬件系统的构成:如图1.42.从功能以及程序涉设计的角度说明计算机系统中软件系统是如何构成的?答:分为系统软件,支撑软件和应用软件三层。

3.什么是操作系统?请举例说明操作系统在计算机系统中的重要地位。

答:操作系统是计算机系统中的一个系统软件,是一些程序模块的集合。

它们能以尽量有效、合理的方式组织和管理计算机的软硬件资源,合理的组织计算机的工作流程,控制程序的执行并向用户提供各种服务功能,使得用户能够灵活、方便、有效的使用计算机,使整个计算机系统能安全高效地运行4.请举一个实际的例子来说明操作系统的功能。

答:你能用用操作系统管理很多资源5.为什么说“操作系统是控制硬件的软件”的说法不确切?答:操作系统不仅能够控制硬件,也可以控制各种软件资源。

6.操作系统的基本特征是什么?说明他们之间的关系。

答:1.并发性2.共享性3.随机性7.试从独立性,并发性和交互性和实时性四个方面来比较批处理系统,分时系统以及实时系统。

答:分时系统:并发性是指同时有多个用户共同使用一个计算机,宏观上看是多个人同时使用一个CPU,微观上是多个人在不同时刻轮流使用CPU.独占性,是指用户感觉不到计算机为他们服务,就好像整个系统为他所独占。

交互性:是指用户根据系统响应结果进一步提出新要求,用户直接干预每一步。

实时性:是指系统对用户提出的请求及时响应。

8.引入多道程序设计技术的起因和目的是什么?多道程序系统的特征是什么?答:多道程序设计的基本思想在内存中保持多个作业,主机可以交替的方式同时处理多个作业,一般来说任何一道作业的运行总是要交替的使用处理器和外设子案9.多道程序设计的度是指在任一给定时刻,单个CPU所能支持的进程数目最大值。

操作系统精髓与设计原理第五版习题与答案

操作系统精髓与设计原理第五版习题与答案

第1章计算机系统概述1.1 列出并简要地定义计算机的四个主要组成部分。

主存储器,存储数据和程序;算术逻辑单元,能处理二进制数据;控制单元,解读存储器中的指令并且使他们得到执行;输入/输出设备,由控制单元管理。

1.2 定义处理器寄存器的两种主要类别。

用户可见寄存器:优先使用这些寄存器,可以使机器语言或者汇编语言的程序员减少对主存储器的访问次数。

对高级语言而言,由优化编译器负责决定把哪些变量应该分配给主存储器。

一些高级语言,如C语言,允许程序言建议编译器把哪些变量保存在寄存器中。

控制和状态寄存器:用以控制处理器的操作,且主要被具有特权的操作系统例程使用,以控制程序的执行。

1.3 一般而言,一条机器指令能指定的四种不同操作是什么?处理器-寄存器:数据可以从处理器传送到存储器,或者从存储器传送到处理器。

处理器-I/O:通过处理器和I/O模块间的数据传送,数据可以输出到外部设备,或者从外部设备输入数据。

数据处理:处理器可以执行很多关于数据的算术操作或逻辑操作。

控制:某些指令可以改变执行顺序。

1.4 什么是中断?中断:其他模块(I/O,存储器)中断处理器正常处理过程的机制。

1.5 多中断的处理方式是什么?处理多中断有两种方法。

第一种方法是当正在处理一个中断时,禁止再发生中断。

第二种方法是定义中断优先级,允许高优先级的中断打断低优先级的中断处理器的运行。

1.6 存层次的各个元素间的特征是什么?存储器的三个重要特性是:价格,容量和访问时间。

1.7 什么是高速缓冲存储器?高速缓冲存储器是比主存小而快的存储器,用以协调主存跟处理器,作为最近储存地址的缓冲区。

1.8 列出并简要地定义I/O操作的三种技术。

可编程I/O:当处理器正在执行程序并遇到与I/O相关的指令时,它给相应的I/O模块发布命令(用以执行这个指令);在进一步的动作之前,处理器处于繁忙的等待中,直到该操作已经完成。

中断驱动I/O:当处理器正在执行程序并遇到与I/O相关的指令时,它给相应的I/O模块发布命令,并继续执行后续指令,直到后者完成,它将被I/O 模块中断。

操作系统第9章课后习题解答

操作系统第9章课后习题解答

9.14 • 在多级反馈队列调度器的调度下,I/Obound的进程比CPU-bound的进程更有利, 也就是说,调度器更倾向于选择I/O-bound 的进程进行分派。原因在于I/O-bound的进 程会比较长时间地阻塞;在阻塞过程中, CPU-bound的进程得到多次分派执行,因而 会很快进入低优先级的反馈队列中。这样, I/O-bound的进程被唤醒之后,通常具有比 CPU-bound的进程高得多的优先级,所以会 得到调度器的“青睐”。
10 7 3.50 8 5 2.50 9 6 3.00 5 2 1.00 5 2 1.00 10 7 3.50 6 3 1.50 8 5 2.50
15 6 1.20 18 9 1.80 19 10 2.00 15 6 1.20 15 6 1.20 15 6 1.20 19 10 2.00 18 9 1.80
9.16
A
ቤተ መጻሕፍቲ ባይዱ
B
C
D
E
平均周转 时间 32.20 30.00 28.80 21.00
RR
45
34 9 24 18
14 39 27 3
27 45 33 9
41 21 45 30
Priority 36 FCFS SPN 15 45
进程
A
B
C
D
E
到达时刻
0
1
3
9
12
服务时间(Ts)
3
5
2
5
5
平均值
FCFS
完成时刻 周转时间(Tr) Tr / Ts 完成时刻 周转时间(Tr) Tr / Ts 完成时刻 周转时间(Tr) Tr / Ts 完成时刻 周转时间(Tr) Tr / Ts 完成时刻 周转时间(Tr) Tr / Ts 完成时刻 周转时间(Tr) Tr / Ts 完成时刻 周转时间(Tr) Tr / Ts 完成时刻 周转时间(Tr) Tr / Ts

计算机操作系统练习题及答案

计算机操作系统练习题及答案

计算机操作系统练习题及答案操作系统是计算机系统中的核心组成部分,它负责管理计算机的硬件和软件资源,为用户提供一个可靠、高效的计算环境。

而练习题则是对操作系统相关知识的巩固和提升,通过解答练习题,可以加深对操作系统原理和技术的理解。

以下是一些常见的计算机操作系统练习题及答案,供大家参考。

1.什么是操作系统?它的主要功能是什么?答案:操作系统是计算机系统的核心软件,它管理和控制计算机的硬件资源,为用户提供一个高效、方便的计算环境。

操作系统的主要功能包括进程管理、内存管理、文件系统管理、设备管理等。

2.简述进程和线程的概念,并指出二者的区别。

答案:进程是程序在计算机中的执行实例,是资源分配的基本单位。

而线程是进程中的一个执行单元,是CPU调度的最小单位。

区别在于进程是独立的执行单位,拥有独立的虚拟地址空间和系统资源;而线程是共享进程的地址空间和系统资源,可以并发执行。

3.请简述死锁的定义及发生的四个必要条件。

答案:死锁是指两个或多个进程在执行过程中,由于竞争资源或彼此等待,导致的无限阻塞的状态。

死锁发生必须满足以下四个条件: - 互斥条件:资源只能被一个进程持有或使用。

- 请求与保持条件:一个进程在持有一部分资源的同时,又请求其他进程正在占有的资源。

- 不剥夺条件:进程在未使用完资源之前,不能被强行剥夺资源。

- 循环等待条件:存在一个进程的资源申请序列,使得每个进程都在等待下一个进程所持有的资源。

4.什么是页式存储管理?请简述页表的作用。

答案:页式存储管理是一种虚拟存储技术,将主存和辅存分成固定大小的页面和页框,以页为单位进行地址映射和数据传输。

页表是一种数据结构,用于存储页面和页框的映射关系。

它的作用是通过页面号将虚拟地址映射到物理地址,实现虚拟地址到物理地址的转换。

5.什么是文件系统?请简述文件系统的组织结构。

答案:文件系统是操作系统用来管理和控制文件的软件部分,提供对文件的创建、读取、写入、删除等操作。

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

习题9参考答案
习题 9
9.1什么是文件?什么是文件系统?文件系统有哪些功能?
答:文件是具有文件名的一组相关信息的集合。

文件系统是指操作系统中与管理文件有关的软件和数据的集合。

文件系统的主要功能:
(1)实现按文件名存取文件信息。

(2)为用户提供统一的和友好的接口。

(3)实施对文件和文件目录的管理。

(4)文件存储器空间的分配和回收。

(5)提供有关文件的共享和保护。

9.2从用户观点看,UNIX或LINUX操作系统将文件分为哪几类?
答:分为如下三类:
普通文件:是指系统中最一般组织格式的文件,一般是字符流组成的无结构文件
目录文件:是由文件的目录信息构成的特殊文件,操作系统将目录也做成文件,便于统一管理
特殊文件:在UNIX或Linux操作系统中,所有的输入输出外部设备都被看作特殊文件便于统一管理
9.3举例说明何种文件长度是固定不变的,何种文件长度是动态变化的。

答:某些系统可执行程序,如shell、vi的长度通常是固定不变的;而用户正在编辑的文本文件或源代码文件的长度通常是动态变化的。

9.4试说明文件系统中对文件操作的系统调用有哪几个?其功能是什么?
答:文件系统中对文件操作的系统调用及功能有:
文件创建Create
文件打开Open
读文件Read
写文件Write
关闭文件Close
删除文件delete
9.5什么是逻辑文件?什么是物理文件?
答:从用户观点看逻辑文件是用户所观察到的文件组织形式,是用户可以直接处理的数据及结构,它独立于物理设备,又称文件组织。

物理文件是与存储介质性能有关的,在外存上存储的组织形式。

9.6逻辑文件包括哪两种类型?
答:无结构文件(流式文件)和有结构文件(记录式文件)。

9.7按文件的物理结构,可将文件分为哪几类?
答:按文件的物理结构,可将文件分为三类:顺序文件、链接文件、索引文件
9.8在MS—DOS中有两个文件A和B,A占用11、12、16和14四个盘块;B占用13、
18和20三个盘块。

试画出在文件A和B中各盘块间的链接情况及FAT的情况。

答:
0 1 2 3 4 5 6 7 8 9
9.9什么是索引文件?为什么要引入多级索引?
答:索引结构将一个逻辑文件的信息存放于外存的若干个物理块中,并为每个文件建立一个索引表,索引表中的每个表目存放文件信息所在的逻辑块号和与之对应的物理块号,以索引结构存放的文件称为索引文件。

当OS为一个大文件分配磁盘空间时,如果所分配出去的盘块的盘块号已经装满一个索引块时,OS便为该文件分配另一个索引块,用于将以后继续为之分配的盘块号记录于其中。

依此类推,再通过链指针将各索引块按序链接起来。

显然,当文件太大,其索引块太多时,这种方法是低效的。

此时,应为这些索引块再建立一级索引,称为第一级索引,即系统再分配一个索引块,作为第一级索引的索引块,将第一块、第二块、……等索引块的盘块号,填入到此索引表中,这样便形成了两级索引分配方式。

如果文件非常大时,还可用三级、四级等多级索引分配方式。

9.10试说明UNⅨ系统中所采用的混合索引分配方式。

答:UNIX系统中采用混合索引分配方式,是指将多种索引分配方式相结合而形成的一种分配方式。

系统既采用了直接地址,又采用了一级索引分配方式,两级索引分配方式,三级索引分配方式。

在UNIX System V的索引结点中,共设有13个地址项,即iaddr(0)-iaddr(12)。

(1)直接地址。

用iaddr(0)~iaddr(9)存放直接地址。

(2)一次间接地址。

地址项iaddr(10)提供一次间接地址。

(3)多次间接地址。

用地址项iaddr(11)提供二次间接地址,地址项iaddr(12)作为三次间接地址。

9.11对文件的存取有哪几种基本方法?
答:顺序存取、直接存取、按键存取。

9.12什么是文件目录?文件目录中一般包含哪些内容?
答:文件目录是文件系统中主要数据结构之一,文件存储后通过用户文件逻辑结构的索引链接找到对应的物理结构。

一级文件目录包含:文件名、记录长度、记录数、起始块号、其他
二级文件目录包含:主目录和用户目录。

主目录包含用户名、UFD大小、UFD物理位置。

用户目录包含文件名、属性、文件物理位置。

多级目录:目录做成文件,目录数据结构等价于一个具有命名边的有向图。

9.13对目录管理的主要要求是什么?
答:(1)实现“按名存取”。

(2)提高检索速度。

(3)允许文件同名。

(4)允许文件共享。

9.14文件控制块中把文件名与文件描述信息分开有什么好处?此时目录项中包含那些
成分?
答:目录项只包含:文件名,索引结点编号
将文件的FCB划分为次部和主部两部分具有如下两个主要的优点:
(1)提高查找速度:查找文件时,需用欲查找的文件名与文件目录中的文件名字相比较。

由于文件目录是存于外存的,比较时需要将其以块为单位读入内存。

由于一个FCB 包括许多信息,一个外存块中所能保存的FCB个数较少,这样查找速度较慢。

将FCB分为两部分之后,文件目录中仅保存FCB的次部,一个外存块中可容纳较多的FCB,从而大大地提高了文件的检索速度。

(2)实现文件连接:所谓连接就是给文件起多个名字,这些名字都是路径名,可为不同的用户所使用。

次部仅包括一个文件名字和一个标识文件主部的文件号,主部则包括除文件名字之外的所有信息和一个标识该主部与多少个次部相对应的连接计数。

当连接计数的值为0时,表示一个空闲未用的FCB主部。

9.15目前广泛采用的目录结构形式是哪种?它有什么优点?
答:多级目录结构,优点:
(1)允许文件重名。

(2)文件查找速度快。

(3)便于实现文件共享。

9.16在Hash检索法中,如何解决“冲突”问题?
答:(1)在利用Hash法索引查找目录时,如果目录表中相应的目录项是空的,则表示系统中并无指定文件。

(2)如果目录项中的文件名与指定文件名相匹配,则表示该目录项正是所要寻找的文件所对应的目录项,故而可从中找到该文件所在的物理地址。

(3)如果在目录表的相应目录项中的文件名与指定文件名并不匹配,则表示发生了“冲突”,此时须将其Hash值再加上一个常数(该常数应与目录的长度值互质),形成新的索引值,再返回到第一步重新开始查找。

9.17文件的存储空间的管理方法有哪几种?
答:空闲表法、空闲链表法、位示图法,成组链表法。

9.18在UNIX操作系统中,是如何对空闲盘块进行分配和回收的?
答:在UNIX操作系统中,文件系统中的空闲盘块引表用栈方式管理空闲盘块。

当块数大于50时,以50块为一组组成若干单向空闲块栈,进行链接。

引表对链中最后一组以栈的方式掌管,分配相当于出栈,回收相当于压栈。

当该组分配完毕,引表指向上一组,以同样方式掌管。

9.19设某系统磁盘共有500块,块号从0-499,若用位示图法管理这500块的盘空间,
当字长为32位时,问:
(1) 位示图需要多少个字?
(2) 第i字第j位对应的块号是多少?
答:(1)500/32=16字
(2)由于每个字可以表示32个磁盘块的状态,因此对应块号是:32×i+j。

9.20基于索引结点的文件共享方式有何优点?
答:由于原来的文件物理地址等信息是放在目录项中的,使得文件增加的部分不能被共享。

引入索引结点后,将文件的物理地址和其他的属性放在索引结点中,只在目录项中存放文件名和指向索引结点的指针。

在索引节点中设有一个链接计数count字段,用于表示链接到本索引节点的目录项的数目。

通过这种方式可以方便的实现文件的共享。

9.21基于符号链的文件共享方式有何优点?
答:只要提供一个机器的网络地址以及文件在该机器上的驻留路径,就可以链接全球任何地方的机器上的文件。

9.22采用文件链接技术后,文件名与文件是否一对一?文件号与文件是否一对一?
答:采用文件链接技术后,文件名与文件是多对一;文件号与文件是一对一。

9.23文件存取控制方式有哪几种?试比较它们的各自优缺点?
答:文件存取控制是解决文件保护、保密和共享。

分为:
(1)用存取控制矩阵和存取控制表:容易实现,便于管理;但当用户和文件较多时,系统开销大。

(2)用户权限表:权限可由用户设定或修改,不能实现完全保密。

(3)使用口令:占存储空间少、方便。

缺点是保护能力弱,更改口令不方便。

(4)使用密码:保密性强。

要求编码技术。

相关文档
最新文档