《操作系统》习题课分析
- 格式:doc
- 大小:89.50 KB
- 文档页数:7
第一章操作系统概论1、有一台计算机,具有IMB 内存,操作系统占用200KB ,每个用户进程各占200KB 。
如果用户进程等待I/O 的时间为80 % ,若增加1MB 内存,则CPU 的利用率提高多少?答:设每个进程等待I/O 的百分比为P ,则n 个进程同时等待刀O 的概率是Pn ,当n 个进程同时等待I/O 期间CPU 是空闲的,故CPU 的利用率为1-Pn。
由题意可知,除去操作系统,内存还能容纳4 个用户进程,由于每个用户进程等待I/O的时间为80 % , 故:CPU利用率=l-(80%)4 = 0.59若再增加1MB 内存,系统中可同时运行9 个用户进程,此时:cPu 利用率=l-(1-80%)9 = 0.87故增加IMB 内存使CPU 的利用率提高了47 % :87 %/59 %=147 %147 %-100 % = 47 %2 一个计算机系统,有一台输入机和一台打印机,现有两道程序投入运行,且程序A 先开始做,程序B 后开始运行。
程序A 的运行轨迹为:计算50ms 、打印100ms 、再计算50ms 、打印100ms ,结束。
程序B 的运行轨迹为:计算50ms 、输入80ms 、再计算100ms ,结束。
试说明(1 )两道程序运行时,CPU有无空闲等待?若有,在哪段时间内等待?为什么会等待?( 2 )程序A 、B 有无等待CPU 的情况?若有,指出发生等待的时刻。
答:画出两道程序并发执行图如下:(1)两道程序运行期间,CPU存在空闲等待,时间为100 至150ms 之间(见图中有色部分)(2)程序A 无等待现象,但程序B 有等待。
程序B 有等待时间段为180rns 至200ms 间(见图中有色部分)3 设有三道程序,按A 、B 、C优先次序运行,其内部计算和UO操作时间由图给出。
试画出按多道运行的时间关系图(忽略调度执行时间)。
完成三道程序共花多少时间?比单道运行节省了多少时间?若处理器调度程序每次进行程序转换化时lms , 试画出各程序状态转换的时间关系图。
操作系统第二版课后习题答案操作系统第二版课后习题答案操作系统是计算机科学中的重要领域,它负责管理计算机硬件和软件资源,为用户提供良好的使用体验。
在学习操作系统的过程中,课后习题是巩固和深化知识的重要方式。
本文将为大家提供操作系统第二版课后习题的答案,帮助读者更好地理解和掌握操作系统的知识。
第一章:引论1. 操作系统的主要功能包括进程管理、内存管理、文件系统管理和设备管理。
2. 进程是指正在执行的程序的实例。
进程控制块(PCB)是操作系统用来管理进程的数据结构,包含进程的状态、程序计数器、寄存器等信息。
3. 多道程序设计是指在内存中同时存放多个程序,通过时间片轮转等调度算法,使得多个程序交替执行。
4. 异步输入输出是指程序执行期间,可以进行输入输出操作,而不需要等待输入输出完成。
第二章:进程管理1. 进程调度的目标包括提高系统吞吐量、减少响应时间、提高公平性等。
2. 进程调度算法包括先来先服务(FCFS)、最短作业优先(SJF)、优先级调度、时间片轮转等。
3. 饥饿是指某个进程长时间得不到执行的情况,可以通过调整优先级或引入抢占机制来解决。
4. 死锁是指多个进程因为争夺资源而陷入无限等待的状态,可以通过资源预分配、避免环路等方式来避免死锁。
第三章:内存管理1. 内存管理的主要任务包括内存分配、内存保护、地址转换等。
2. 连续内存分配包括固定分区分配、可变分区分配和动态分区分配。
3. 分页和分段是常见的非连续内存分配方式,分页将进程的地址空间划分为固定大小的页,分段将进程的地址空间划分为逻辑段。
4. 页面置换算法包括最佳置换算法、先进先出(FIFO)算法、最近最久未使用(LRU)算法等。
第四章:文件系统管理1. 文件是操作系统中用来存储和组织数据的逻辑单位,可以是文本文件、图像文件、音频文件等。
2. 文件系统的主要功能包括文件的创建、删除、读取、写入等操作。
3. 文件系统的组织方式包括层次目录结构、索引结构、位图结构等。
第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.1:存储程序式计算机的主要特点是:集中顺序过程控制(1)过程性:模拟人们手工操作(2)集中控制:由CPU集中管理(3)顺序性:程序计数器1.2:a:批处理系统的特点:早期批处理有个监督程序,作业自动过渡直到全部处理完,而脱机批处理的特点:主机与卫星机并行操作。
b:分时系统的特点:(1):并行性。
共享一台计算机的众多联机用户可以在各自的终端上同时处理自己的程序。
(2):独占性。
分时操作系统采用时间片轮转的方法使一台计算机同时为许多终端上同时为许多终端用户服务,每个用户的感觉是自己独占计算机。
操作系统通过分时技术将一台计算机改造为多台虚拟计算机。
(3):交互性。
用户与计算机之间可以进行“交互会话”,用户从终端输入命令,系统通过屏幕(或打印机)将信息反馈给用户,用户与系统这样一问一答,直到全部工作完成。
c:分时系统的响应比较快的原因:因为批量操作系统的作业周转时间较长,而分时操作系统一般采用时间片轮转的方法,一台计算机与许多终端设备连接,使一台计算机同时为多个终端用户服务,该系统对每个用户都能保证足够快的响应时间,并提供交互会话功能。
1.3:实时信息处理系统和分时系统的本质区别:实时操作系统要追求的目标是:对外部请求在严格时间范围内做出反应,有高可靠性和完整性。
其主要特点是资源的分配和调度首先要考虑实时性然后才是效率。
此外,实时操作系统应有较强的容错能力,分时操作系统的工作方式是:一台主机连接了若干个终端,每个终端有一个用户在使用。
用户交互式地向系统提出命令请求,系统接受每个用户的命令,采用时间片轮转方式处理服务请求,并通过交互方式在终端上向用户显示结果。
用户根据上步结果发出下道命。
分时操作系统将CPU 的时间划分成若干个片段,称为时间片。
操作系统以时间片为单位,轮流为每个终端用户服务。
每个用户轮流使用一个时间片而使每个用户并不感到有别的用户存在。
分时系统具有多路性、交互性、“独占”性和及时性的特征。
习题二参考答案4、答:在生产者—消费者问题中,Producer进程中P(empty)和P(mutex)互换先后次序。
先执行P(mutex),假设成功,生产者进程获得对缓冲区的访问权,但如果此时缓冲池已满,没有空缓冲区可供其使用,后续的P(empty)原语没有通过,Producer阻塞在信号量empty 上,而此时mutex已被改为0,没有恢复成初值1。
切换到消费者进程后,Consumer进程执行P(full)成功,但其执行P(mutex)时由于Producer正在访问缓冲区,所以不成功,阻塞在信号量mutex上。
生产者进程和消费者进程两者均无法继续执行,相互等待对方释放资源,会产生死锁。
在生产者和消费者进程中,V操作的次序无关紧要,不会出现死锁现象。
5、答:6、答:设信号量sp用于控制对盘子的互斥操作,信号量sg1用于计数,表示盘子中的苹果数目,信号量sg2用于计数,表示盘子中的桔子数目。
Semaphore sp=1,sg1=0,sg2=0dad(){while(1){ prepare an apple;p(sp);put an apple on the plate;v(sg2);}}mom(){while(1){prepare an orange;p(sp);put an orange on the plate;v(sg1);}}son(){while(1){p(sg1);take an orange from the plate;v(sg);eat the orange;}}daughter(){while(1){p(sg2);take an apple from the plate;v(sg);eat the apple;}}7、答:为了使写者优先,在原来的读优先算法基础上增加一个初值为1的信号量S,使得当至少有一个写者准备访问共享对象时,它可使后续的读者进程等待写完成;初值为0的整型变量writecount,用来对写者进行计数;初值为1的互斥信号量wmutex,用来实现多个写者对writecount的互斥访问。
CHAPTER 9 Virtual Memory Practice Exercises9.1 Under what circumstances do page faults occur? Describe the actions taken by the operating system when a page fault occurs.Answer:A page fault occurs when an access to a page that has not beenbrought into main memory takes place. The operating system verifiesthe memory access, aborting the program if it is invalid. If it is valid, a free frame is located and I/O is requested to read the needed page into the free frame. Upon completion of I/O, the process table and page table are updated and the instruction is restarted.9.2 Assume that you have a page-reference string for a process with m frames (initially all empty). The page-reference string has length p;n distinct page numbers occur in it. Answer these questions for any page-replacement algorithms:a. What is a lower bound on the number of page faults?b. What is an upper bound on the number of page faults?Answer:a. nb. p9.3 Consider the page table shown in Figure 9.30 for a system with 12-bit virtual and physical addresses and with 256-byte pages. The list of freepage frames is D, E, F (that is, D is at the head of the list, E is second, and F is last).Convert the following virtual addresses to their equivalent physical addresses in hexadecimal. All numbers are given in hexadecimal. (A dash for a page frame indicates that the page is not in memory.)• 9EF• 1112930 Chapter 9 Virtual Memory• 700• 0FFAnswer:• 9E F - 0E F• 111 - 211• 700 - D00• 0F F - EFF9.4 Consider the following page-replacement algorithms. Rank these algorithms on a five-point scale from “bad” to “perfect” according to their page-fault rate. Separate those algorithms that suffer from Belady’s anomaly from those that do not.a. LRU replacementb. FIFO replacementc. Optimal replacementd. Second-chance replacementAnswer:Rank Algorithm Suffer from Belady’s anomaly1 Optimal no2 LRU no3 Second-chance yes4 FIFO yes9.5 Discuss the hardware support required to support demand paging. Answer:For every memory-access operation, the page table needs to be consulted to check whether the corresponding page is resident or not and whether the program has read or write privileges for accessing the page. These checks have to be performed in hardware. A TLB could serve as a cache and improve the performance of the lookup operation.9.6 An operating system supports a paged virtual memory, using a central processor with a cycle time of 1 microsecond. It costs an additional 1 microsecond to access a page other than the current one. Pages have 1000 words, and the paging device is a drum that rotates at 3000 revolutions per minute and transfers 1 million words per second. The following statistical measurements were obtained from the system:• 1 percent of all instructions executed accessed a page other than the current page.•Of the instructions that accessed another page, 80 percent accesseda page already in memory.Practice Exercises 31•When a new page was required, the replaced page was modified 50 percent of the time.Calculate the effective instruction time on this system, assuming that the system is running one process only and that the processor is idle during drum transfers.Answer:effective access time = 0.99 × (1 sec + 0.008 × (2 sec)+ 0.002 × (10,000 sec + 1,000 sec)+ 0.001 × (10,000 sec + 1,000 sec)= (0.99 + 0.016 + 22.0 + 11.0) sec= 34.0 sec9.7 Consider the two-dimensional array A:int A[][] = new int[100][100];where A[0][0] is at location 200 in a paged memory system with pages of size 200. A small process that manipulates the matrix resides in page 0 (locations 0 to 199). Thus, every instruction fetch will be from page 0. For three page frames, how many page faults are generated bythe following array-initialization loops, using LRU replacement andassuming that page frame 1 contains the process and the other twoare initially empty?a. for (int j = 0; j < 100; j++)for (int i = 0; i < 100; i++)A[i][j] = 0;b. for (int i = 0; i < 100; i++)for (int j = 0; j < 100; j++)A[i][j] = 0;Answer:a. 5,000b. 509.8 Consider the following page reference string:1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 2, 3, 7, 6, 3, 2, 1, 2, 3, 6.How many page faults would occur for the following replacement algorithms, assuming one, two, three, four, five, six, or seven frames? Remember all frames are initially empty, so your first unique pages will all cost one fault each.•LRU replacement• FIFO replacement•Optimal replacement32 Chapter 9 Virtual MemoryAnswer:Number of frames LRU FIFO Optimal1 20 20 202 18 18 153 15 16 114 10 14 85 8 10 76 7 10 77 77 79.9 Suppose that you want to use a paging algorithm that requires a referencebit (such as second-chance replacement or working-set model), butthe hardware does not provide one. Sketch how you could simulate a reference bit even if one were not provided by the hardware, or explain why it is not possible to do so. If it is possible, calculate what the cost would be.Answer:You can use the valid/invalid bit supported in hardware to simulate the reference bit. Initially set the bit to invalid. O n first reference a trap to the operating system is generated. The operating system will set a software bit to 1 and reset the valid/invalid bit to valid.9.10 You have devised a new page-replacement algorithm that you thinkmaybe optimal. In some contorte d test cases, Belady’s anomaly occurs. Is the new algorithm optimal? Explain your answer.Answer:No. An optimal algorithm will not suffer from Belady’s anomaly because —by definition—an optimal algorithm replaces the page that will notbe used for the long est time. Belady’s anomaly occurs when a pagereplacement algorithm evicts a page that will be needed in the immediatefuture. An optimal algorithm would not have selected such a page.9.11 Segmentation is similar to paging but uses variable-sized“pages.”Definetwo segment-replacement algorithms based on FIFO and LRU pagereplacement schemes. Remember that since segments are not the samesize, the segment that is chosen to be replaced may not be big enoughto leave enough consecutive locations for the needed segment. Consider strategies for systems where segments cannot be relocated, and thosefor systems where they can.Answer:a. FIFO. Find the first segment large enough to accommodate the incoming segment. If relocation is not possible and no one segmentis large enough, select a combination of segments whose memoriesare contiguous, which are “closest to the first of the list” andwhich can accommodate the new segment. If relocation is possible, rearrange the memory so that the firstNsegments large enough forthe incoming segment are contiguous in memory. Add any leftover space to the free-space list in both cases.Practice Exercises 33b. LRU. Select the segment that has not been used for the longestperiod of time and that is large enough, adding any leftover spaceto the free space list. If no one segment is large enough, selecta combination of the “oldest” segments that are contiguous inmemory (if relocation is not available) and that are large enough.If relocation is available, rearrange the oldest N segments to be contiguous in memory and replace those with the new segment.9.12 Consider a demand-paged computer system where the degree of multiprogramming is currently fixed at four. The system was recently measured to determine utilization of CPU and the paging disk. The results are one of the following alternatives. For each case, what is happening? Can the degree of multiprogramming be increased to increase the CPU utilization? Is the paging helping?a. CPU utilization 13 percent; disk utilization 97 percentb. CPU utilization 87 percent; disk utilization 3 percentc. CPU utilization 13 percent; disk utilization 3 percentAnswer:a. Thrashing is occurring.b. CPU utilization is sufficiently high to leave things alone, and increase degree of multiprogramming.c. Increase the degree of multiprogramming.9.13 We have an operating system for a machine that uses base and limit registers, but we have modified the machine to provide a page table.Can the page tables be set up to simulate base and limit registers? How can they be, or why can they not be?Answer:The page table can be set up to simulate base and limit registers provided that the memory is allocated in fixed-size segments. In this way, the base of a segment can be entered into the page table and the valid/invalid bit used to indicate that portion of the segment as resident in the memory. There will be some problem with internal fragmentation.9.27.Consider a demand-paging system with the following time-measured utilizations:CPU utilization 20%Paging disk 97.7%Other I/O devices 5%Which (if any) of the following will (probably) improve CPU utilization? Explain your answer.a. Install a faster CPU.b. Install a bigger paging disk.c. Increase the degree of multiprogramming.d. Decrease the degree of multiprogramming.e. Install more main memory.f. Install a faster hard disk or multiple controllers with multiple hard disks.g. Add prepaging to the page fetch algorithms.h. Increase the page size.Answer: The system obviously is spending most of its time paging, indicating over-allocationof memory. If the level of multiprogramming is reduced resident processeswould page fault less frequently and the CPU utilization would improve. Another way toimprove performance would be to get more physical memory or a faster paging drum.a. Get a faster CPU—No.b. Get a bigger paging drum—No.c. Increase the degree of multiprogramming—No.d. Decrease the degree of multiprogramming—Yes.e. Install more main memory—Likely to improve CPU utilization as more pages canremain resident and not require paging to or from the disks.f. Install a faster hard disk, or multiple controllers with multiple hard disks—Also animprovement, for as the disk bottleneck is removed by faster response and morethroughput to the disks, the CPU will get more data more quickly.g. Add prepaging to the page fetch algorithms—Again, the CPU will get more datafaster, so it will be more in use. This is only the case if the paging action is amenableto prefetching (i.e., some of the access is sequential).h. Increase the page size—Increasing the page size will result in fewer page faults ifdata is being accessed sequentially. If data access is more or less random, morepaging action could ensue because fewer pages can be kept in memory and moredata is transferred per page fault. So this change is as likely to decrease utilizationas it is to increase it.10.1、Is disk scheduling, other than FCFS scheduling, useful in asingle-userenvironment? Explain your answer.Answer: In a single-user environment, the I/O queue usually is empty. Requests generally arrive from a single process for one block or for a sequence of consecutive blocks. In these cases, FCFS is an economical method of disk scheduling. But LOOK is nearly as easy to program and will give much better performance when multiple processes are performing concurrent I/O, such as when aWeb browser retrieves data in the background while the operating system is paging and another application is active in the foreground.10.2.Explain why SSTF scheduling tends to favor middle cylindersover theinnermost and outermost cylinders.The center of the disk is the location having the smallest average distance to all other tracks.Thus the disk head tends to move away from the edges of the disk.Here is another way to think of it.The current location of the head divides the cylinders into two groups.If the head is not in the center of the disk and a new request arrives,the new request is more likely to be in the group that includes the center of the disk;thus,the head is more likely to move in that direction.10.11、Suppose that a disk drive has 5000 cylinders, numbered 0 to 4999. The drive is currently serving a request at cylinder 143, and the previous request was at cylinder 125. The queue of pending requests, in FIFO order, is86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130Starting from the current head position, what is the total distance (in cylinders) that the disk arm moves to satisfy all the pending requests, for each of the following disk-scheduling algorithms?a. FCFSb. SSTFc. SCANd. LOOKe. C-SCANAnswer:a. The FCFS schedule is 143, 86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130. The total seek distance is 7081.b. The SSTF schedule is 143, 130, 86, 913, 948, 1022, 1470, 1509, 1750, 1774. The total seek distance is 1745.c. The SCAN schedule is 143, 913, 948, 1022, 1470, 1509, 1750, 1774, 4999, 130, 86. The total seek distance is 9769.d. The LOOK schedule is 143, 913, 948, 1022, 1470, 1509, 1750, 1774, 130, 86. The total seek distance is 3319.e. The C-SCAN schedule is 143, 913, 948, 1022, 1470, 1509, 1750, 1774, 4999, 86, 130. The total seek distance is 9813.f. (Bonus.) The C-LOOK schedule is 143, 913, 948, 1022, 1470, 1509, 1750, 1774, 86, 130. The total seek distance is 3363.12CHAPTERFile-SystemImplementationPractice Exercises12.1 Consider a file currently consisting of 100 blocks. Assume that the filecontrol block (and the index block, in the case of indexed allocation)is already in memory. Calculate how many disk I/O operations are required for contiguous, linked, and indexed (single-level) allocation strategies, if, for one block, the following conditions hold. In the contiguous-allocation case, assume that there is no room to grow atthe beginning but there is room to grow at the end. Also assume thatthe block information to be added is stored in memory.a. The block is added at the beginning.b. The block is added in the middle.c. The block is added at the end.d. The block is removed from the beginning.e. The block is removed from the middle.f. The block is removed from the end.Answer:The results are:Contiguous Linked Indexeda. 201 1 1b. 101 52 1c. 1 3 1d. 198 1 0e. 98 52 0f. 0 100 012.2 What problems could occur if a system allowed a file system to be mounted simultaneously at more than one location?Answer:4344 Chapter 12 File-System ImplementationThere would be multiple paths to the same file, which could confuse users or encourage mistakes (deleting a file with one path deletes thefile in all the other paths).12.3 Wh y must the bit map for file allocation be kept on mass storage, ratherthan in main memory?Answer:In case of system crash (memory failure) the free-space list would notbe lost as it would be if the bit map had been stored in main memory.12.4 Consider a system that supports the strategies of contiguous, linked, and indexed allocation. What criteria should be used in deciding which strategy is best utilized for a particular file?Answer:•Contiguous—if file is usually accessed sequentially, if file isrelatively small.•Linked—if file is large and usually accessed sequentially.• Indexed—if file is large and usually accessed randomly.12.5 One problem with contiguous allocation is that the user must preallocate enough space for each file. If the file grows to be larger than thespace allocated for it, special actions must be taken. One solution to this problem is to define a file structure consisting of an initial contiguous area (of a specified size). If this area is filled, the operating system automatically defines an overflow area that is linked to the initial contiguous area. If the overflow area is filled, another overflow areais allocated. Compare this implementation of a file with the standard contiguous and linked implementations.Answer:This method requires more overhead then the standard contiguousallocation. It requires less overheadthan the standard linked allocation. 12.6 How do caches help improve performance? Why do systems not use more or larger caches if they are so useful?Answer:Caches allow components of differing speeds to communicate moreefficiently by storing data from the slower device, temporarily, ina faster device (the cache). Caches are, almost by definition, more expensive than the device they are caching for, so increasing the numberor size of caches would increase system cost.12.7 Why is it advantageous for the user for an operating system todynamically allocate its internal tables? What are the penalties to the operating system for doing so?Answer:Dynamic tables allow more flexibility in system use growth — tablesare never exceeded, avoiding artificial use limits. Unfortunately, kernelstructures and code are more complicated, so there is more potentialfor bugs. The use of one resource can take away more system resources (by growing to accommodate the requests) than with static tables.Practice Exercises 4512.8 Explain how the VFS layer allows an operating system to support multiple types of file systems easily.Answer:VFS introduces a layer of indirection in the file system implementation.In many ways, it is similar to object-oriented programming techniques. System calls can be made generically (independent of file system type). Each file system type provides its function calls and data structuresto the VFS layer. A system call is translated into the proper specific functions for the target file system at the VFS layer. The calling program has no file-system-specific code, and the upper levels of the system callst ructures likewise are file system-independent. The translation at the VFS layer turns these generic calls into file-system-specific operations.。
《操作系统教程》(笫5版)教学重点、难点及解决办法(按十个核心知识单元排列)1、概念与原理重点:操作系统的发展历史、定义、作用、功能、特征、分类、发展动力和研究动向;操作系统在计算机系统中的地位,以及与其他软件的联系与区别;操作系统的资源管理技术:复用、虚拟和抽象;操作系统三个最基本抽象:进程抽象、虚存抽象和文件抽象;操作系统虚拟机及其实现原理;多道程序设计定义、实现基础、基本原理、主要特征、优点缺点。
难点:对并发性和共享性及其关系的深刻理解;多道程序运行的时间关系、处理器及设备利用率计算;操作系统在计算机系统中的地位和作用;操作系统与其他软件的联系与区别;对操作系统三个最基本抽象的深刻理解,虚拟机的定义及其实现原理。
解决办法:讲解操作系统是计算机系统的核心和灵魂,是各类软件系统中最复杂的软件之一,是软件系统中的基础软件;提醒学生注意学习方法、激发学习兴趣,学习本课程最终目标是建立起以操作系统为中心的计算机系统的系统级的认识和全局性把握;强调操作系统是理论性与实践性并重的课程,理论与实践相结合十分重要,既要学好原理,又要动手实践,做到课程教学与实验内容彼此呼应、掌握基本原理与提高编程能力相互并重;多道程序设计是讲授的重点之一,让学生理解和掌握多道程序设计原理,实现它必须解决的若干问题,基本调度思想,理解计算机效率的计算方法;可通过图解方法介绍操作系统三个最基本抽象,在此基础上再介绍虚拟机,让学生牢固掌握操作系统资源管理技术;本知识单元主要要求是讲清楚“操作系统是什么?为什么要它?它干什么?它如何干?”等问题,回顾操作系统的发展历史和分类,有助于理解操作系统的实质,提醒学生带着以上问题学习操作系统;建议学生多看参考书和参考资料,多浏览相关网站,并为学生提供这类信息资源。
2、接口与服务重点:操作系统接口、操作系统服务;POSIX标准、访管指令、应用编程接口API、标准库函数;程序接口与系统调用;操作接口与系统程序;shell概念、变量、命令、语句及其简单程序设计。
第三章处理机调度与死锁1,高级调度与低级调度的主要任务是什么?为什么要引入中级调度?【解】(1)高级调度主要任务是用于决定把外存上处于后备队列中的那些作业调入内存,并为它们创建进程,分配必要的资源,然后再将新创建的进程排在就绪队列上,准备执行。
(2)低级调度主要任务是决定就绪队列中的哪个进程将获得处理机,然后由分派程序执行把处理机分配给该进程的操作。
(3)引入中级调度的主要目的是为了提高内存的利用率和系统吞吐量。
为此,应使那些暂时不能运行的进程不再占用宝贵的内存空间,而将它们调至外存上去等待,称此时的进程状态为就绪驻外存状态或挂起状态。
当这些进程重又具备运行条件,且内存又稍有空闲时,由中级调度决定,将外存上的那些重又具备运行条件的就绪进程重新调入内存,并修改其状态为就绪状态,挂在就绪队列上,等待进程调度。
3、何谓作业、作业步和作业流?【解】作业包含通常的程序和数据,还配有作业说明书。
系统根据该说明书对程序的运行进行控制。
批处理系统中是以作业为基本单位从外存调入内存。
作业步是指每个作业运行期间都必须经过若干个相对独立相互关联的顺序加工的步骤。
作业流是指若干个作业进入系统后依次存放在外存上形成的输入作业流;在操作系统的控制下,逐个作业进程处理,于是形成了处理作业流。
4、在什么情冴下需要使用作业控制块JCB?其中包含了哪些内容?【解】每当作业进入系统时,系统便为每个作业建立一个作业控制块JCB,根据作业类型将它插入到相应的后备队列中。
JCB 包含的内容通常有:1) 作业标识2)用户名称3)用户账户4)作业类型(CPU 繁忙型、I/O芳名型、批量型、终端型)5)作业状态6)调度信息(优先级、作业已运行)7)资源要求8)进入系统时间9) 开始处理时间10) 作业完成时间11) 作业退出时间12) 资源使用情况等5.在作业调度中应如何确定接纳多少个作业和接纳哪些作业?【解】作业调度每次接纳进入内存的作业数,取决于多道程序度。
第一章绪论1.什么是操作系统的基本功能?答:操作系统的职能是管理和控制汁算机系统中的所有硬、软件资源,合理地组织计算机工作流程,并为用户提供一个良好的工作环境和友好的接口。
操作系统的基本功能包括:处理机管理、存储管理、设备管理、信息管理(文件系统管理)和用户接口等。
2.什么是批处理、分时和实时系统?各有什么特征?答:批处理系统(batchprocessingsystem):操作员把用户提交的作业分类,把一批作业编成一个作业执行序列,由专门编制的监督程序(monitor)自动依次处理。
其主要特征是:用户脱机使用计算机、成批处理、多道程序运行。
分时系统(timesharingoperationsystem):把处理机的运行时间分成很短的时间片,按时间片轮转的方式,把处理机分配给各进程使用。
其主要特征是:交互性、多用户同时性、独立性。
实时系统(realtimesystem):在被控对象允许时间范围内作出响应。
其主要特征是:对实时信息分析处理速度要比进入系统快、要求安全可靠、资源利用率低。
3.多道程序(multiprogramming)和多重处理(multiprocessing)有何区别?答;多道程序(multiprogramming)是作业之间自动调度执行、共享系统资源,并不是真正地同时值行多个作业;而多重处理(multiprocessing)系统配置多个CPU,能真正同时执行多道程序。
要有效使用多重处理,必须采用多道程序设计技术,而多道程序设计原则上不一定要求多重处理系统的支持。
6.设计计算机操作系统时与那些硬件器件有关运算器、控制器、存储器、输入设备、输出设备第二章作业管理和用户接口2.作业由哪几部分组成?各有什么功能?答:作业由三部分组成:程序、数据和作业说明书。
程序和数据完成用户所要求的业务处理工作,作业说明书则体现用户的控制意图。
3.作业的输入方式有哪几种?各有何特点答:作业的输入方式有5种:联机输入方式、脱机输入方式、直接耦合方式、SPOOLING(Simultaneous Peripheral OperationsOnline)系统和网络输入方式,各有如下特点:(1)联机输入方式:用户和系统通过交互式会话来输入作业。
(完整版)操作系统课后题答案课本课后题部分答案第⼀章1.设计现代OS的主要⽬标是什么?答:(1)有效性(2)⽅便性(3)可扩充性(4)开放性2.OS的作⽤可表现在哪⼏个⽅⾯?答:(1)OS作为⽤户与计算机硬件系统之间的接⼝(2)OS作为计算机系统资源的管理者(3)OS实现了对计算机资源的抽象13.OS有哪⼏⼤特征?其最基本的特征是什么?答:并发性、共享性、虚拟性和异步性四个基本特征;最基本的特征是并发性。
14.处理机管理有哪些主要功能?它们的主要任务是什么?答:处理机管理的主要功能是:进程管理、进程同步、进程通信和处理机调度;进程管理:为作业创建进程,撤销已结束进程,控制进程在运⾏过程中的状态转换。
进程同步:为多个进程(含线程)的运⾏进⾏协调。
通信:⽤来实现在相互合作的进程之间的信息交换。
处理机调度:(1)作业调度。
从后备队⾥按照⼀定的算法,选出若⼲个作业,为他们分配运⾏所需的资源(⾸选是分配内存)。
(2)进程调度:从进程的就绪队列中,按照⼀定算法选出⼀个进程,把处理机分配给它,并设置运⾏现场,使进程投⼊执⾏。
15.内存管理有哪些主要功能?他们的主要任务是什么?北京⽯油化⼯学院信息⼯程学院计算机系3/48《计算机操作系统》习题参考答案余有明与计07和计G09的同学们编著 3/48答:内存管理的主要功能有:内存分配、内存保护、地址映射和内存扩充。
内存分配:为每道程序分配内存。
内存保护:确保每道⽤户程序都只在⾃⼰的内存空间运⾏,彼此互不⼲扰。
地址映射:将地址空间的逻辑地址转换为内存空间与对应的物理地址。
内存扩充:⽤于实现请求调⽤功能,置换功能等。
16.设备管理有哪些主要功能?其主要任务是什么?答:主要功能有: 缓冲管理、设备分配和设备处理以及虚拟设备等。
主要任务: 完成⽤户提出的I/O 请求,为⽤户分配I/O 设备;提⾼CPU 和I/O 设备的利⽤率;提⾼I/O速度;以及⽅便⽤户使⽤I/O设备.17.⽂件管理有哪些主要功能?其主要任务是什么?答:⽂件管理主要功能:⽂件存储空间的管理、⽬录管理、⽂件的读/写管理和保护。
操作系统罗宇课后习题答案操作系统罗宇课后习题答案操作系统作为计算机科学中的重要课程,是计算机专业学生必修的一门课程。
学习操作系统的过程中,除了理论知识的学习,还需要通过习题来巩固所学内容。
本文将针对操作系统罗宇教材中的一些习题进行解答,帮助读者更好地理解和掌握操作系统的知识。
1. 什么是进程?进程的状态有哪些?进程是指在计算机系统中正在运行的一个程序。
它是操作系统进行资源分配和调度的基本单位。
进程的状态包括:- 就绪状态(Ready):进程已经具备运行的条件,等待系统分配资源。
- 运行状态(Running):进程正在执行指令。
- 阻塞状态(Blocked):进程由于等待某个事件的发生而暂停执行。
- 终止状态(Terminated):进程执行完毕或被操作系统终止。
2. 什么是线程?线程和进程的区别是什么?线程是进程中的一个执行流程,是操作系统调度和执行的基本单位。
一个进程可以包含多个线程,它们共享进程的资源。
线程和进程的区别主要有:- 资源开销:线程的创建、切换和销毁的开销较小,而进程的开销较大。
- 并发性:不同线程可以并发执行,共享进程的资源。
而不同进程之间的并发执行需要通过进程间通信来实现。
- 独立性:线程是进程的一部分,同一进程中的线程共享进程的地址空间和文件描述符等资源。
而不同进程之间是相互独立的。
- 启动方式:线程的创建和销毁由程序员控制,而进程的创建和销毁由操作系统控制。
3. 什么是死锁?如何避免死锁?死锁是指两个或多个进程因争夺资源而无法继续执行的状态。
死锁发生时,进程无法进行下去,系统资源被浪费。
为了避免死锁,可以采取以下策略:- 预防死锁:通过破坏死锁产生的四个必要条件(互斥、占有并等待、不可剥夺、循环等待)来预防死锁的发生。
- 避免死锁:通过资源分配策略,避免系统进入可能导致死锁的状态。
例如,银行家算法可以根据系统资源的最大需求进行资源分配,避免死锁的发生。
- 检测死锁:通过系统资源的状态和进程的状态来检测死锁的发生。
6. 设备管理6.1 例题解析例6.2.1 何谓虚拟设备?请说明SPOOLing系统是如何实现虚拟设备的。
解本题的考核要点是虚拟设备的实现方法。
虚拟设备是指利用软件方法,比如SPOOLing系统,把独享设备分割为若干台逻辑上的独占的设备,使用户感受到系统有出若干独占设备在运行。
当然,系统中至少一台拥有物理设备,这是虚拟设备技术的基础。
SPOOLing系统又称“假脱机I/O系统”,其中心思想是,让共享的、高速的、大容量外存储器(比如,磁盘)来模拟若干台独占设备,使系统中的一台或少数几台独占设备变成多台可并行使用的虚拟设备。
SPOOLing系统主要管理外存上的输入井和输出井,以及内存中的输入缓冲区和输出缓冲区。
其管理进程主要有输入和输出进程,负责将输入数据装入到输入井,或者将输出井的数据送出。
它的特点是:提高了I/O操作的速度;将独占设备改造为共享设备;实现了虚拟设备功能。
例6.2.2有关设备管理要领的下列叙述中,( )是不正确的。
A.通道是处理输入、输出的软件B.所有外围设备都由系统统一来管理C.来自通道的I/O中断事件由设备管理负责处理D.编制好的通道程序是存放在主存贮器中的E.由用户给出的设备编号是设备的绝对号解本题的考核要点是设备管理的基本概念。
(1)通道是计算机上配置的一种专门用于输入输出的设备,是硬件的组成部分。
因此A是错误的。
(2)目前常见I/O系统其外部设备的驱动和输入输出都由系统统一管理。
因此B是对的。
(3)设备管理模块中的底层软件中配有专门处理设备中断的处理程序。
通道中断属于设备中断的一种。
因此C是对的。
(4)通道设备自身只配有一个简单的处理装置(CPU),并不配有存储器,它所运行的通道程序全部来自内存。
因此D是对的。
(5)系统在初启时为每台物理设备赋予一个绝对号,设备绝对号是相互独立的。
由用户给出的设备号只能是逻辑编号,由系统将逻辑号映射为绝对号。
因此E是错误的。
0 6. 设备管理112例6.2.3 在关于SPOOLING 的叙述中, 描述是不正确的。
1.什么是操作系统?其主要功能是什么?操作系统是控制和管理计算机系统各种硬件和软件资源,有效组织多道程序运行的系统软件(或程序集合),是用户和计算机直接的程序接口.2.在某个计算机系统中,有一台输入机和一台打印机,现有两道程序投入运行,程序A、B 同时运行,A略早于B。
A的运行轨迹为:计算50ms、打印100ms、再计算50ms、打印100ms,结束。
B的运行轨迹为:计算50ms、输入80ms、再计算100ms,结束。
试说明:(1)两道程序运行时,CPU是否空闲等待?若是,在那段时间段等待?(2)程序A、B是否有等待CPU的情况?若有,指出发生等待的时刻。
0 50 100 150 200 250 30050 100 50 10050 100 20100(1)cpu有空闲等待,在100ms~150ms的时候.(2)程序A没有等待cpu,程序B发生等待的时间是180ms~200ms.1.设公共汽车上,司机和售票员的活动如下:司机的活动:启动车辆;正常行车;到站停车。
售票员的活动:关车门;售票;开车门。
在汽车不断的到站、停车、行驶过程中,用信号量和P、V操作实现这两个活动的同步关系。
semaphore s1,s2;s1=0;s2=0;cobegin司机();售票员();coendprocess 司机(){while(true){P(s1);启动车辆;正常行车;到站停车;V(s2);}}process 售票员(){while(true){关车门;V(s1);售票;P(s2);开车门;上下乘客;}}2.设有三个进程P、Q、R共享一个缓冲区,该缓冲区一次只能存放一个数据,P进程负责循环地从磁带机读入数据并放入缓冲区,Q进程负责循环地从缓冲区取出P进程放入的数据进行加工处理,并把结果放入缓冲区,R进程负责循环地从缓冲区读出Q进程放入的数据并在打印机上打印。
请用信号量和P、V操作,写出能够正确执行的程序。
semaphore sp,sq,sr;int buf;sp=1;sq=0;sr=0;cobeginprocess P(){while(true){从磁带读入数据;P(sp);Buf=data;V(sq);}}process Q(){while(true){P(sq);data=buf;加工data;buf=data;V(sr);}}process R(){while(true){P(sr);data=buf;V(sp);打印数据;}}coend.3.简述计数信号量的值与资源使用情况的关系。
操作系统教程课后习题参考答案习题一习题二习题三习题四习题五习题六习题一1.设计操作系统的主要目的是什么?设计操作系统的目的是:(1)从系统管理人员的观点来看,设计操作系统是为了合理地去组织计算机工作流程,管理和分配计算机系统硬件及软件资源,使之能为多个用户所共享。
因此,操作系统是计算机资源的管理者。
(2)从用户的观点来看,设计操作系统是为了给用户使用计算机提供一个良好的界面,以使用户无需了解许多有关硬件和系统软件的细节,就能方便灵活地使用计算机。
2.操作系统的作用可表现在哪几个方面?(1) 方便用户使用:操作系统通过提供用户与计算机之间的友好界面来方便用户使用。
(2) 扩展机器功能:操作系统通过扩充硬件功能和提供新的服务来扩展机器功能。
(3) 管理系统资源:操作系统有效地管理系统中的所有硬件和软件资源,使之得到充分利用。
(4) 提高系统效率:操作系统合理组织计算机的工作流程,以改进系统性能和提高系统效率。
(5)构筑开放环境:操作系统遵循国际标准来设计和构造一个开放环境。
其含义主要是指:遵循有关国际工业标准和开放系统标准,支持体系结构的可伸缩性和可扩展性;支持应用程序在不同平台上的可移植性和互操作性。
3.试叙述脱机批处理和联机批处理工作过程(1)联机批处理工作过程用户上机前,需向机房的操作员提交程序、数据和一个作业说明书,后者提供了用户标识、用户想使用的编译程序以及所需的系统资源等基本信息。
这些资料必须变成穿孔信息,(例如穿成卡片的形式),操作员把各用户提交的一批作业装到输入设备上(若输入设备是读卡机,则该批作业是一叠卡片),然后由监督程序控制送到磁带上。
之后,监督程序自动输入第一个作业的说明记录,若系统资源能满足其要求,则将该作业的程序、数据调入主存,并从磁带上调入所需要的编译程序。
编译程序将用户源程序翻译成目标代码,然后由连接装配程序把编译后的目标代码及所需的子程序装配成一个可执行的程序,接着启动执行。
计算题类型:
1.重定位地址计算:
1)给定逻辑地址,计算物理地址(分段或分页,一级页表或二级页表)
2)给定逻辑地址LA,页长度,计算逻辑地址的页号和偏移
3)给定物理地址RA,页帧长度,计算物理地址的页帧号和偏移
2.有效内存访问时间计算:
给定内存访问时间、快表访问时间及快表命中率、调页时间及缺页率,计算有效内存访问时间
3.磁盘地址及容量计算:
1)给定一维的逻辑扇区编址A,柱面数C、磁头数H、扇区数S,计算物
理c、h、s
2)给定柱面数C、磁头数H、扇区数S,计算磁盘容量
4.文件系统相关计算:
1)给定inode数据结构,盘块大小,地址长度,计算文件最大容量
2)给定卷的容量,簇大小,FAT12/16/32分别需要多少个簇来存放FAT表
3)给定RAID5阵列的磁盘数量n,计算磁盘空间有效利用率
5.给定作业到达时刻、计算时间长度,调度策略,计算响应时间、周转时间
例1:在某个采用分页存储管理的系统中,假定逻辑页面和物理存储块的大小
均为1KB,主存容量为10KB。
某个用户编写的程序P共有4个页面,
被分别装入到主存的第3、4、6、8存储块中。
(1)写出P对应进程的页面映射表;
(2)当P在CPU运行时,执行了一条指令:MOV [2100],[3100]
请计算指令中的两个操作数的物理地址。
解答:(1)由于页大小为长。
页表应为:
(2
例2:在请求分页式存储管理中,假设一次内存访问时间为100ns,一次快表(TLB)访问时间为20ns,地址转换计算时的快表命中率为80%,请计算
平均有效内存访问时间为多少ns?若缺页率为1‰,且每次缺页中断处
理时间为20ms,请计算平均有效内存访问时间为多少ns?
解答:
如果快表命中(即页号在快表中),则内存访问时间A1=20+100=120ns
如果快表未命中,则内存访问时间
A2=20+100+100=220ns【含一次访问内存中页表】则平均有效内存访问时间
A=A1×80%+A2×20%=120×0.8+220×0.2=140ns
缺页率p=1‰的含义是,每1000次内存访问中有1次需要调页处理!
因此,请求分页式存储管理过程中,平均有效内存访问时间:
T = (1-p)×A+p×20(ms)
=(1-0.001)×140 + 0.001×20000000(ns)
=139.86+20000
=20139ns
【注】1s=1000ms=1000 000us=1000 000 000ns
例3:假设一个磁盘共有2048个柱面,16个磁头,每个磁道分为64个扇区,
每个扇区容量为512字节,请计算该磁盘的总容量有多少GB?假设磁
盘的一个逻辑盘块大小为2KB,则逻辑盘块号513所对应的首个扇区
的三维物理地址(c,h,s)为多少?
解答:
(1)C=2048=2K个柱面(即每个盘面有2K个磁道)
H=16个磁头(即16个盘面)S=64个扇区/每个磁道
每个扇区的容量=512字节=0.5KB
则磁盘总容量=0.5KB×C×H×S = 0.5KB×2K×16×64 = 1GB
(2)1个盘块由2KB/0.5K=4个扇区构成
因此,513号盘块的首块扇区号A=4×513=2052
s = A % S = 2052 % 64= 4
h = ⌊A / S⌋ % H = ⌊2052 / 64⌋ % 16 = 0
c = ⌊A / (S×H)⌋ = ⌊2052 / (64×16)⌋ = 2
结果=(2,0,4)
例4-1:RAID5磁盘阵列共有8块磁盘构成,请计算磁盘空间有效利用率?解答:磁盘空间有效利用率= (n-1) / n = 7 / 8 = 87.5%
例4-2:已知磁盘容量为256MB,簇大小为4KB,对FAT16格式的文件系统
来说,文件分配表应该占用多大磁盘空间?(不考虑文件系统的空间开销)解答:整个磁盘逻辑盘块(簇)个数= 256MB/4KB = 256×1024 / 4 = 64K个FAT16文件格式的文件分配表每项占用16bit即2B空间
因此,文件分配表占用空间= 2B×64K = 128KB,即128KB/4KB=32个簇
例4-3:MINIX文件系统1.0中,每个文件均有唯一的一个inode数据结构,
其中共有9个文件数据块指针zone[0..8],每个指针为short类型。
前
7个即zone[0..6]为直接数据块指针,zone[7]为一级数据块指针,zone[8]
为二级数据块指针。
而每个数据块大小为1KB。
试计算该文件系统能
够支持的最大文件是多大?
解答:数据块大小为1KB,而每个指针为short整型,占2B空间,因此1个数据块可以有512个指针。
inode的直接数据块有7个,即可以指出7KB的空间;
inode的一级间接指针块,共有512个指针,可以指出512×1KB = 0.5MB 空间;
inode的二级间接指针块,共有512个指针,可以指出512个一级指针块,共可以指出512×512个数据块,即可以指出512×512×1KB = 0.25GB
空间。
因此,MINIX文件系统1.0的单个文件最大容量为0.25GB+0.5MB+7KB
例5:给定作业到达时刻、计算时间长度,调度策略,计算响应时间、周转时
间
采用SRFS(调度执行结果甘特图:
则响应时间(提交到第1次执行):
5
61
8
13
20
30
42
例6:在银行家算法中,系统有5个进程和3类资源。
若出现以下资源分配情况:
目前状态是否为安全状态?如果是安全状态,给出一个安全序列,否则给出死锁进程集合。
解答:
(1)P1、P3、P0、P2、P4
(2)P1、P3、P0、P4、P2
(3)P1、P3、P2、P0、P4
(4)P1、P3、P2、P4、P0
(5)P1、P3、P4、P0、P2
(6)P1、P3、P4、P2、P0
(7)P1、P4、P3、P0、P2
(8)P1、P4、P3、P2、P0
(9)P3、P1、P0、P2、P4
(10)P3、P1、P0、P4、P2
(11)P3、P1、P2、P0、P4
(12)P3、P1、P2、P4、P0
(13)P3、P1、P4、P0、P2
(14)P3、P1、P4、P2、P0
(15)P3、P4、P1、P0、P2
(16)P3、P4、P1、P2、P0
调度策略:
1.CPU调度(进程调度)
FCFS(先来先服务)、
SJF(最短作业优先)、
SRJF(最短剩余时间作业优先)、
RR(时间片轮转)
四种方式的作业(任务)调度执行结果的甘特图,并通过甘特图计算响应时间、周转时间等
2.虚拟内存的缺页置换
FIFO(先进先出);OPT(MIN)(最优置换);LRU(最近最少使用);LRU的准确实现算法(计数器算法、页码栈算法);LRU的近似实现算法(CLOCK 算法)
针对各种具体置换策略或算法,计算缺页数及缺页率
3.磁盘调度
FCFS(先来先服务)、
SSTF(最短寻道时间优先)、
SCAN(扫描/电梯法)、
LOOK(查看扫描/电梯法)
CSCAN(周期扫描法)
CLOOK(周期查看扫描)
六种调度策略的寻道移动磁道数量计算
进程状态变迁及条件
三状态、五状态、七状态
算法:
银行家算法检测死锁
哲学家进餐问题
信号量控制互斥、同步程序编写
简答题例子:
(1)解释什么是并行和并发?
答案:并行是指两个或多个活动在同一时刻同时执行的情况;
并发是指系统中存在着若干个逻辑上相互独立的程序或程序段,它们都已经被启动执行,在相对短的时间内,它们交叉地在CPU上执行的情况。
给使用者一个并行的感觉。
(2)进程与程序之间的联系与区别?
答案:进程是程序的一次执行过程,没有程序就没有进程;
程序是完成某个特定功能的一系列程序语句的集合,只要不被破坏,它就永远存在;
程序是一个静态的概念,而进程是一个动态的概念,它由创建而产生,完成任务后因撤销而消亡;进程是系统进行资源分配和调度的独立单位,而程序不是。
选择题例子:
(1)如果分时系统的时间片一定,那么( A ),则响应时间越长。
A 用户数越多
B 用户数越少
C 主存容量越大
D 主存容量越小
(2)在分时系统中,当用户数为100时,为保证响应时间不超过2s,系统设置的时间片应为(D)。
A 50ms
B 100ms
C 10ms
D 20ms
(3)若信号量S的初值为2,当前值为-1,则表示有(B)个等待进程。
A 0
B 1
C 2
D 3
判断题例子:
死锁是指系统中的全部进程都处于阻塞状态。
【×】
一个程序在执行过程中可能产生多进程。
【√】
P、V操作既可以用来实现进程间的同步,也可以实现进程间互斥。
【√】
当进程调度未能选中一个进程运行时,就绪队列和阻塞队列一定为空。
【×】。