最新《操作系统精髓与设计原理·第五版》习题答案

合集下载

操作系统第五版习题中文解答-精共18页PPT

操作系统第五版习题中文解答-精共18页PPT
45、自己的饭量自己知道。——苏联
操作系统第五版习题中文解答-精
16、人民应该为法律而战斗,就像为 了城墙 而战斗 一样。 ——赫 拉克利 特 17、人类对于不公正的行为加以指责 ,并非 因为他 们愿意 做出这 种行为 ,而是 惟恐自 己会成 为这种 行为的 牺牲者 。—— 柏拉图 18、制定法律法令,就是为了不让强 者做什 么事都 横行霸 道。— —奥维 德 19、法律是社会的习惯和思想的结晶 。—— 托·伍·威尔逊 20、人们嘴上挂着的法律,其真实含 义是财 富。— —爱献 生
41、学问是异常珍贵的东西,从任何源泉吸 收都不可耻。——阿卜·日·法拉兹
42、只有在人群中间,才能认识自 己。——德国
43、重复别人所说的话,只需要教育; 而要挑战别人所说的话,则需要头脑。—— 玛丽· Nhomakorabea蒂博恩·普尔
44、卓越的人一大优点是:在不利与艰 难的遭遇里百折不饶。——贝多芬

计算机操作系统第五版答案,操作系统-第5版-习题答案.doc

计算机操作系统第五版答案,操作系统-第5版-习题答案.doc

计算机操作系统第五版答案,操作系统-第5版-习题答案.doc 第⼀章⼀、选择题1. D2. C3,B4.A5.6. D7. C⼆、填空题1. 硬件、软件2. 交互性、多路性和独占性3.⾬提⾼系统的⼯作效率4.处理器管理、存储器管理、⽂件管理、设备管理和接⼝管理。

5. 程序级和⽤户组(程序接⼝和命令接⼝)。

三、简答题1.计算机系统由哪些部分组成?处理器管理、存储器管理、⽂件管理、设备管理和接⼝管理2. 什么是操作系统?(1)管理和控制计算机的硬件和软件资源。

(2)合理组织计算机⼯作流程。

(3)提供⽅便⽤户操作的接⼝的软件。

3. 实时操作系统的主要特点是什么?及时性、可靠性。

4. 从资源管理的⾓度来看,操作系统的基本功能可分成哪些部分?管理和控制计算机的硬件和软件资源。

5. 操作系统的分类?(1)批处理操作系统。

(2)实时操作系统。

(3)分时操作系统。

(4)⽹络操作系统。

(5)分布式操作系统。

(6)嵌⼊式操作系统。

(7)微型计算机操作系统。

第⼆章⼀、选择题(1)进程部分1. D2. B3,D4.B5.6. B7. B(2)并发和通信部分1. B2. B3.B4.B5.D6. C7. B8.11. B 12.D⼆、填空题1. 动态和静态。

2. 程序、数据和PCB(进程控制块)3. 程序、数据和PCB(进程控制块、PCB、程序段。

4. 动态、静态5. 分配资源的基本单位,执⾏和调度单位6. 临界资源的概念是 ⼀次仅允许⼀个进程访问的资源 ,⽽临界区是指进程中访问临界资源的那段程序代码。

7. ⽤PV操作管理临界区时,任何⼀个进程进⼊临界区之间必须应⽤P操作,退出临界区必须调⽤V操作。

8. 信息分信箱头和信箱体,信箱头中存放有关信箱的描述,信箱体由若⼲格⼦组成,每格存放⼀封信件,格⼦的数⽬和⼤⼩在创建信箱时确定。

三、简答题1. 什么叫多道程序设计?为什么要采⽤多道程序设计?答:多道程序设计是指在主存中同时存放多个程序,它们都处于执⾏的开始点和结束点之间,这些程序轮渡或以其他⽅式共享CPU。

操作系统第五版--精髓与设计概要第7章课后习题答案2

操作系统第五版--精髓与设计概要第7章课后习题答案2

7.1.如果使用动态分区方案,下图所示为在某个给定的时间点的内存配置:阴影部分为已经被分配的块;空白部分为空闲块。

接下来的三个内存需求分别为40MB,20MB和10MB。

分别使用如下几种放置算法,指出给这三个需求分配的块的起始地址。

a.首次适配b.最佳适配c.临近适配(假设最近添加的块位于内存的开始)d.最坏适配答:a.40M的块放入第2个洞中,起始地址是80M. 20M的块放入第一个洞中.起始地址是20M. 10M的块的起始地址是120M。

b.40M,20N,10M的起始地址分别为230M,20M和160M.c.40M,20M,10M的起始地址是80M,120160M.d.40M,20M,10M,的起始地址是80M,230M,360M.7.2.使用伙伴系统分配一个1MB的存储块。

a.利用类似于图7.6的图来说明按下列顺序请求和返回的结果:请求70;请求35;请求80;返回A;请求60;返回B;返回D;返回C。

b.给出返回B之后的二叉树表示。

答:a.b.7.3.考虑一个伙伴系统,在当前分配下的一个特定块地址为011011110000.a.如果块大小为4,它的伙伴的二进制地址为多少?b.如果块大小为16,它的伙伴的二进制地址为多少?答:a.011011110100b.0110111000007.4.令buddy k(x)为大小为2k、地址为x的块的伙伴的地址,写出buddy k(x)的通用表达式。

答:7.5.Fabonacci序列定义如下:F0=0,F1=1,F n+2=F n+1+F n,n≧0a.这个序列可以用于建立伙伴系统吗?b.该伙伴系统与本章介绍的二叉伙伴系统相比,有什么优点?答:a.是。

字区大小可以确定Fn = Fn-1 + Fn-2.。

b.这种策略能够比二叉伙伴系统提供更多不同大小的块,因而具有减少内部碎片的可能性。

但由于创建了许多没用的小块,会造成更多的外部碎片。

7.6.在程序执行期间,每次取指令后处理器把指令寄存器的内容(程序计数器)增加一个字,但如果遇到会导致在程序中其他地址继续执行的转跳或调用指令,处理器将修改这个寄存器的内容。

操作系统精髓与设计原理第五版中文答案全

操作系统精髓与设计原理第五版中文答案全

•2.1 情况(a)和情况(b)具有相同的答案。

•假设处理器的操作不能重叠,但I/O操作可以。

•1job:时间周期=NT•处理器利用率=50%;•2jobs:时间周期=NT•处理器利用率=100%;•4jobs:时间周期=(2N-1)NT•处理器利用率=100%•2.2 I/O限制程序只用相对较少的处理时间,因此,受到短期调度算法的偏爱。

然而,如果一个处理器限制程序在一段很长的时间内被处理器时间拒绝,那同样的这个短期调度算法则会允许处理机去处理过去一段时间一直没有使用处理机的程序,所以,并不是永远不受理处理器限制程序所需的处理器时间。

•2.3 关于分时系统,我们所关注的是周转时间。

•首选的是时间片,因为它在一个很短的时间给•所有的程序一个访问权限去使用处理器。

在批•处理系统,我们所关注的是吞吐量和更少量的上•下文转换,对于进程来说获得了更多的处理时•间。

因此,最小化上下文转换的处理是有优势•的。

•2.4 应用程序运用系统调用去调用操作系统所•提供的功能。

关键的是,系统调用导致转换到•进入内核模式的系统程序。

操作系统第三章习题解答•3.1 系统和用户进程的创建和删除:在系统中进程对于信息共享,加速计算,模块性和便利性都能并发执行。

并发的执行需要进程的创建和删除机制。

进程所需要的资源在进程被创建时获得或者在其运行的时候分配。

当进程结束时,操作系统需要收回任何可重用资源。

•进程的挂起和恢复:在进程调度中,当进程在等待某些资源时,操作系统需要把进程状态改变成等待或者就绪状态。

当进程所要求的资源可用时,操作系统需要把它的状态变为运行状态恢复它的执行。

•进程同步机制:协调进程分享数据。

并发访问使用共享数据可能导致数据不一致性,操作系统不得不为其提供一种进程同步机制用来确保协作进程有序的实行,从而保证数据的一致性。

•进程通信机制:在操作系统下执行的进程要么是独立的进程要么是协作的进程。

协作进程必须使用某些方法来实现进程间的通信。

(完整)《操作系统精髓与设计原理·第五版》练习题及答案(DOC)

(完整)《操作系统精髓与设计原理·第五版》练习题及答案(DOC)

第1章计算机系统概述1。

1、图1.3中的理想机器还有两条I/O指令:0011 = 从I/O中载入AC0111 = 把AC保存到I/O中在这种情况下,12位地址标识一个特殊的外部设备。

请给出以下程序的执行过程(按照图1.4的格式):1.从设备5中载入AC。

2.加上存储器单元940的内容.3.把AC保存到设备6中。

假设从设备5中取到的下一个值为3940单元中的值为2。

答案:存储器(16进制内容):300:3005;301:5940;302:7006步骤1:3005-〉IR;步骤2:3->AC步骤3:5940-〉IR;步骤4:3+2=5-〉AC步骤5:7006-〉IR:步骤6:AC-〉设备 61。

2、本章中用6步来描述图1。

4中的程序执行情况,请使用MAR和MBR扩充这个描述。

答案:1。

a。

PC中包含第一条指令的地址300,该指令的内容被送入MAR中。

b。

地址为300的指令的内容(值为十六进制数1940)被送入MBR,并且PC增1。

这两个步骤是并行完成的。

c。

MBR中的值被送入指令寄存器IR中。

2。

a。

指令寄存器IR中的地址部分(940)被送入MAR中。

b. 地址940中的值被送入MBR中。

c。

MBR中的值被送入AC中。

3. a. PC中的值(301)被送入MAR中.b. 地址为301的指令的内容(值为十六进制数5941)被送入MBR,并且PC增1。

c. MBR中的值被送入指令寄存器IR中。

4. a。

指令寄存器IR中的地址部分(941)被送入MAR中。

b. 地址941中的值被送入MBR中。

c。

AC中以前的内容和地址为941的存储单元中的内容相加,结果保存到AC中。

5. a。

PC中的值(302)被送入MAR中。

b. 地址为302的指令的内容(值为十六进制数2941)被送入MBR,并且PC增1。

c. MBR中的值被送入指令寄存器IR中。

6。

a。

指令寄存器IR中的地址部分(941)被送入MAR中。

操作系统_精髓与设计原理(第五版)答案.William Stallings

操作系统_精髓与设计原理(第五版)答案.William Stallings

-2-
NOTICE
This manual contains solutions to all of the review questions and homework problems in Operating Systems, Fifth Edition . If you spot an error in a solution or in the wording of a problem, I would greatly appreciate it if you would forward the information via email to me at ws@. An errata sheet for this manual, if needed, is available at ftp:///members/w/s/ws/S/ W.S.
-4-
CHAPTER 1 COMPUTER SYSTEM OVERVIEW A NSWERS
TO
Q UESTIONS
1.1 A main memory, which stores both data and instructions: an arithmetic and logic unit (ALU) capable of operating on binary data; a control unit, which interprets the instructions in memory and causes them to be executed; and input and output (I/O) equipment operated by the control unit. 1.2 User-visible registers: Enable the machine- or assembly-language programmer to minimize main memory references by optimizing register use. For high-level languages, an optimizing compiler will attempt to make intelligent choices of which variables to assign to registers and which to main memory locations. Some highlevel languages, such as C, allow the programmer to suggest to the compiler which variables should be held in registers. Control and status registers: Used by the processor to control the operation of the processor and by privileged, operating system routines to control the execution of programs. 1.3 These actions fall into four categories: Processor-memory: Data may be transferred from processor to memory or from memory to processor. Processor-I/O: Data may be transferred to or from a peripheral device by transferring between the processor and an I/O module. Data processing: The processor may perform some arithmetic or logic operation on data. Control: An instruction may specify that the sequence of execution be altered. 1.4 An interrupt is a mechanism by which other modules (I/O, memory) may interrupt the normal sequencing of the processor. 1.5 Two approaches can be taken to dealing with multiple interrupts. The first is to disable interrupts while an interrupt is being processed. A second approach is to define priorities for interrupts and to allow an interrupt of higher priority to cause a lower-priority interrupt handler to be interrupted. 1.6 The three key characteristics of memory are cost, capacity, and access time. 1.7 Cache memory is a memory that is smaller and faster than main memory and that is interposed between the processor and main memory. The cache acts as a buffer for recently used memory locations. 1.8 Programmed I/O: The processor issues an I/O command, on behalf of a process, to an I/O module; that process then busy-waits for the operation to be completed before proceeding. Interrupt-driven I/O: The processor issues an I/O command on behalf of a process, continues to execute subsequent instructions, and is interrupted by the I/O module when the latter has completed its work. The subsequent instructions may be in the same process, if it is not necessary for that process to wait for the completion of the I/O. Otherwise, the process is suspended pending the interrupt and other work is performed. Direct memory access (DMA): A DMA -5-

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

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

第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 模块中断。

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

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

操作系统精髓与设计原理第五版课后题答案C HAPTER 2O PERATING S YSTEMO VERVIEWReview Questions2.1 Convenience: An operating system makes a computer more convenientto use. Efficiency: An operating system allows the computer systemresources to be used in an efficient manner. Ability to evolve: Anoperating system should be constructed in such a way as to permit theeffective development, testing, and introduction of new systemfunctions without interfering with service.2.5 The execution context, or process state, is the internal data by which theoperating system is able to supervise and control the process. Thisinternal information is separated from the process, because theoperating system has information not permitted to the process. Thecontext includes all of the information that the operating system needsto manage the process and that the processor needs to execute theprocess properly. The context includes the contents of the variousprocessor registers, such as the program counter and data registers. Italso includes information of use to the operating system, such as thepriority of the process and whether the process is waiting for thecompletion of a particular I/O event.Problems2.1 The answers are the same for (a) and (b). Assume that althoughprocessor operations cannot overlap, I/O operations can.1 Job: TAT = NT Processor utilization = 50%2 Jobs: TAT = NT Processor utilization = 100%4 Jobs: TAT = (2N – 1)NT Processor utilization = 100% 2.4 A system call is used by an application program to invoke a functionprovided by the operating system. Typically, the system call results intransfer to a system program that runs in kernel mode.C HAPTER 3P ROCESS D ESCRIPTION ANDC ONTROLReview Questions3.5 Swapping involves moving part or all of a process from main memoryto disk. When none of the processes in main memory is in the Ready state, the operating system swaps one of the blocked processes out onto disk into a suspend queue, so that another process may be brought into main memory to execute.3.10 The user mode has restrictions on the instructions that can be executedand the memory areas that can be accessed. This is to protect theoperating system from damage or alteration. In kernel mode, theoperating system does not have these restrictions, so that it canperform its tasks.Problems3.1 •Creation and deletion of both user and system processes. Theprocesses in the system can execute concurrently for informationsharing, computation speedup, modularity, and convenience.Concurrent execution requires a mechanism for process creation and deletion. The required resources are given to the process when it iscreated, or allocated to it while it is running. When the processterminates, the OS needs to reclaim any reusable resources.•Suspension and resumpti on of processes. In process scheduling, theOS needs to change the process's state to waiting or ready state when it is waiting for some resources. When the required resources areavailable, OS needs to change its state to running state to resume itsexecution.•Provision of mechanism for process synchronization. Cooperatingprocesses may share data. Concurrent access to shared data mayresult in data inconsistency. OS has to provide mechanisms forprocesses synchronization to ensure the orderly execution ofcooperating processes, so that data consistency is maintained.•Provision of mechanism for process communication. The processesexecuting under the OS may be either independent processes orcooperating processes. Cooperating processes must have the meansto communicate with each other.•Provision of mechanisms for deadlock handling. In amultiprogramming environment, several processes may compete fora finite number of resources. If a deadlock occurs, all waitingprocesses will never change their waiting state to running state again, resources are wasted and jobs will never be completed.3.3Figure 9.3 shows the result for a single blocked queue. The figurereadily generalizes to multiple blocked queues.C HAPTER 4P ROCESS D ESCRIPTION ANDC ONTROLReview Questions4.2 Less state information is involved.4.5 Address space, file resources, execution privileges are examples.4.6 1. Thread switching does not require kernel mode privileges becauseall of the thread management data structures are within the useraddress space of a single process. Therefore, the process does notswitch to the kernel mode to do thread management. This saves theoverhead of two mode switches (user to kernel; kernel back to user). 2.Scheduling can be application specific. One application may benefit most from a simple round-robin scheduling algorithm, while another might benefit from a priority-based scheduling algorithm. Thescheduling algorithm can be tailored to the application withoutdisturbing the underlying OS scheduler. 3. ULTs can run on anyoperating system. No changes are required to the underlying kernel to support ULTs. The threads library is a set of application-level utilities shared by all applications.4.7 1. In a typical operating system, many system calls are blocking. Thus,when a ULT executes a system call, not only is that thread blocked, but also all of the threads within the process are blocked. 2. In a pure ULT strategy, a multithreaded application cannot take advantage ofmultiprocessing. A kernel assigns one process to only one processor ata time. Therefore, only a single thread within a process can execute at atime.Problems4.2Because, with ULTs, the thread structure of a process is not visible to theoperating system, which only schedules on the basis of processes.C HAPTER 5C ONCURRENCY:M UTUALE XCLUSION ANDS YNCHRONIZATIONReview Questions5.1 Communication among processes, sharing of and competing forresources, synchronization of the activities of multiple processes, and allocation of processor time to processes.5.9 A binary semaphore may only take on the values 0 and 1. A generalsemaphore may take on any integer value.Problems5.2 ABCDE; ABDCE; ABDEC; ADBCE; ADBEC; ADEBC;DEABC; DAEBC; DABEC; DABCE5.5Consider the case in which turn equals 0 and P(1) sets blocked[1] totrue and then finds blocked[0] set to false. P(0) will then setblocked[0] to true, find turn = 0, and enter its critical section. P(1) will then assign 1 to turn and will also enter its critical section.C HAPTER 6C ONCURRENCY:D EADLOCK ANDS TARVATIONReview Questions6.2 Mutual exclusion. Only one process may use a resource at a time. Holdand wait. A process may hold allocated resources while awaitingassignment of others. No preemption. No resource can be forciblyremoved from a process holding it.6.3 The above three conditions, plus: Circular wait. A closed chain ofprocesses exists, such that each process holds at least one resourceneeded by the next process in the chain.Problems6.4 a. 0 0 0 00 7 5 06 6 2 22 0 0 20 3 2 0b. to d. Running the banker's algorithm, we see processes can finishin the order p1, p4, p5, p2, p3.e. Change available to (2,0,0,0) and p3's row of "still needs" to (6,5,2,2).Now p1, p4, p5 can finish, but with available now (4,6,9,8) neitherp2 nor p3's "still needs" can be satisfied. So it is not safe to grantp3's request.6.5 1. W = (2 1 0 0)2. Mark P3; W = (2 1 0 0) + (0 1 2 0) = (2 2 2 0)3. Mark P2; W = (2 2 2 0) + (2 0 0 1) = (4 2 2 1)4. Mark P1; no deadlock detectedReview Questions7.1 Relocation, protection, sharing, logical organization, physicalorganization.7.7 A logical address is a reference to a memory location independent ofthe current assignment of data to memory; a translation must be made to a physical address before the memory access can be achieved. A relative address is a particular example of logical address, in which the address is expressed as a location relative to some known point, usually the beginning of the program. A physical address, or absolute address, is an actual location in main memory.Problems7.6 a. The 40 M block fits into the second hole, with a starting address of80M. The 20M block fits into the first hole, with a starting address of 20M. The 10M block is placed at location 120M.40M 40M 60M 40M 40M 40M 30Mb. The three starting addresses are 230M, 20M, and 160M, for the 40M, 20M, and 10M blocks, respectively. 40M 60M 60M 40M 40M 40M 30Mc. The three starting addresses are 80M, 120M, and 160M, for the 40M,20M, and 10M blocks, respectively. C HAPTER 7M EMORY M ANAGEMENT7.12 a. The number of bytes in the logical address space is (216 pages) (210bytes/page) = 226 bytes. Therefore, 26 bits are required for the logical address.b. A frame is the same size as a page, 210 bytes.c. The number of frames in main memory is (232 bytes of mainmemory)/(210 bytes/frame) = 222 frames. So 22 bits is needed tospecify the frame.d. There is one entry for each page in the logical address space.Therefore there are 216 entries.e. In addition to the valid/invalid bit, 22 bits are needed to specify theframe location in main memory, for a total of 23 bits.30M40M40M60M40M40M40Md. The three starting addresses are 80M, 230M, and 360M, for the 40M,20M, and 10M blocks, respectively.C HAPTER 8V IRTUAL M EMORYReview Questions8.1 Simple paging: all the pages of a process must be in main memory forprocess to run, unless overlays are used. Virtual memory paging: not all pages of a process need be in main memory frames for the process to run.; pages may be read in as needed8.2 A phenomenon in virtual memory schemes, in which the processorspends most of its time swapping pieces rather than executinginstructions.Problems8.1 a. Split binary address into virtual page number and offset; use VPNas index into page table; extract page frame number; concatenateoffset to get physical memory addressb. (i) 1052 = 1024 + 28 maps to VPN 1 in PFN 7, (7 ⨯ 1024+28 = 7196)(ii) 2221 = 2 ⨯ 1024 + 173 maps to VPN 2, page fault(iii) 5499 = 5 ⨯ 1024 + 379 maps to VPN 5 in PFN 0, (0 ⨯ 1024+379 =379)8.4 a. PFN 3 since loaded longest ago at time 20b. PFN 1 since referenced longest ago at time 160c. Clear R in PFN 3 (oldest loaded), clear R in PFN 2 (next oldestloaded), victim PFN is 0 since R=0d. Replace the page in PFN 3 since VPN 3 (in PFN 3) is used furthestin the futuree. There are 6 faults, indicated by **4 0 0 0 *2*4 2*1**3 2VPN of pages in memory in LRU order 32143243434242241241243122Review Questions9.1 Long-term scheduling: The decision to add to the pool of processes tobe executed. Medium-term scheduling: The decision to add to thenumber of processes that are partially or fully in main memory.Short-term scheduling: The decision as to which available process willbe executed by the processor9.3 Turnaround time is the total time that a request spends in the system(waiting time plus service time. Response time is the elapsed timebetween the submission of a request until the response begins toappear as output.Problems9.1 Each square represents one time unit; the number in the square refersto the currently-running process.FCFS A A A B B B B B C C D D D D D E E E E E RR, q = 1 A B A B C A B C B D B D E D E D E D E E RR, q = 4 A A A B B B B C C B D D D D E E E E D E SPN A A A C C B B B B B D D D D D E E E E E SRT A A A C C B B B B B D D D D D E E E E E HRRN A A A B B B B B C C D D D D D E E E E E Feedback, q = 1 A B A C B C A B B D B D E D E D E D E EFeedback, q = 2i A B A A C B B C B B D D E D D E E D E EC HAPTER 9U NIPROCESSORS CHEDULINGA B C D ET a0 1 3 9 12T s 3 5 2 5 5 FCFS T f 3 8 10 15 20T r 3.00 7.00 7.00 6.00 8.00 6.20T r/T s 1.00 1.40 3.50 1.20 1.60 1.74 RR qT f 6.00 11.00 8.00 18.00 20.00= 1T r 6.00 10.00 5.00 9.00 8.00 7.60T r/T s 2.00 2.00 2.50 1.80 1.60 1.98RR qT f 3.00 10.00 9.00 19.00 20.00= 4T r 3.00 9.00 6.00 10.00 8.00 7.20T r/T s 1.00 1.80 3.00 2.00 1.60 1.88 SPN T f 3.00 10.00 5.00 15.00 20.00T r 3.00 9.00 2.00 6.00 8.00 5.60T r/T s 1.00 1.80 1.00 1.20 1.60 1.32SRT T f 3.00 10.00 5.00 15.00 20.00T r 3.00 9.00 2.00 6.00 8.00 5.60T r/T s 1.00 1.80 1.00 1.20 1.60 1.32 HRRT f 3.00 8.00 10.00 15.00 20.00NT r 3.00 7.00 7.00 6.00 8.00 6.20T r/T s 1.00 1.40 3.50 1.20 1.60 1.74FB qT f7.00 11.00 6.00 18.00 20.00= 1T r7.00 10.00 3.00 9.00 8.00 7.40T r/T s 2.33 2.00 1.50 1.80 1.60 1.85 FB T f 4.00 10.00 8.00 18.00 20.00q = 2i T r 4.00 9.00 5.00 9.00 8.00 7.00 T r/T s 1.33 1.80 2.50 1.80 1.60 1.819.16 a. Sequence with which processes will get 1 min of processor time:1 2 3 4 5 Elapsed timeA A A A A A A A A A A A A A BBBBBBBBCCDDDDDEEEEEEEEEEE1015192327303336384042434445The turnaround time for each process:A = 45 min,B = 35 min,C = 13 min,D = 26 min,E = 42 minThe average turnaround time is = (45+35+13+26+42) / 5 = 32.2 min b.Priority Job Turnaround Time3 4 6 7 9 BEACD99 + 12 = 2121 + 15 = 3636 + 3 = 3939 + 6 = 45The average turnaround time is: (9+21+36+39+45) / 5 = 30 min c.Job Turnaround TimeA B C D E 1515 + 9 = 24 24 + 3 = 27 27 + 6 = 33 33 + 12 = 45The average turnaround time is: (15+24+27+33+45) / 5 = 28.8 min d.RunningTimeJob Turnaround Time6 9 12 15 DBEA3 + 6 = 99 + 9 = 1818 + 12 = 3030 + 15 = 45The average turnaround time is: (3+9+18+30+45) / 5 = 21 minC HAPTER 10M ULTIPROCESSOR AND R EAL-T IMES CHEDULINGReview Questions10.1 Fine: Parallelism inherent in a single instruction stream. Medium: Parallelprocessing or multitasking within a single application. Coarse:Multiprocessing of concurrent processes in a multiprogrammingenvironment. Very Coarse: Distributed processing across network nodes toform a single computing environment. Independent: Multiple unrelatedprocesses.10.4 A hard real-time task is one that must meet its deadline; otherwise it willcause undesirable damage or a fatal error to the system. A soft real-timetask has an associated deadline that is desirable but not mandatory; it stillmakes sense to schedule and complete the task even if it has passed itsdeadline.Problems10.1 For fixed priority, we do the case in which the priority is A, B, C. Eachsquare represents five time units; the letter in the square refers to thecurrently-running process. The first row is fixed priority; the secondrow is earliest deadline scheduling using completion deadlines.A AB B A AC C A A B B A A C C A AA AB B AC C A C A A B B A A C C C A AFor fixed priority scheduling, process C always misses its deadline.10.4normal executionexecution in critical sectionT 1T 2T 3s locked by T 3s unlockeds locked by T 1Once T 3 enters its critical section, it is assigned a priority higher than T1. When T3 leaves its critical section, it is preempted by T 1.C HAPTER 11I/O M ANAGEMENT AND D ISK S CHEDULING Review Questions11.1 Programmed I/O: The processor issues an I/O command, on behalf of aprocess, to an I/O module; that process then busy-waits for theoperation to be completed before proceeding. Interrupt-driven I/O:The processor issues an I/O command on behalf of a process,continues to execute subsequent instructions, and is interrupted by the I/O module when the latter has completed its work. The subsequent instructions may be in the same process, if it is not necessary for that process to wait for the completion of the I/O. Otherwise, the process is suspended pending the interrupt and other work is performed. Direct memory access (DMA): A DMA module controls the exchange of data between main memory and an I/O module. The processor sends arequest for the transfer of a block of data to the DMA module and is interrupted only after the entire block has been transferred.11.5 Seek time, rotational delay, access time.Problems11.1 If the calculation time exactly equals the I/O time (which is the mostfavorable situation), both the processor and the peripheral devicerunning simultaneously will take half as long as if they ran separately.Formally, let C be the calculation time for the entire program and let T be the total I/O time required. Then the best possible running timewith buffering is max(C, T), while the running time without buffering is C + T; and of course ((C + T)/2) ≤ max(C, T) ≤ (C + T). Source:[KNUT97].11.3 Disk head is initially moving in the direction of decreasing tracknumber:FIFO SSTF SCAN C-SCANNext track accessed Numberof trackstraversedNexttrackaccessedNumberof trackstraversedNexttrackaccessedNumberof trackstraversedNexttrackaccessedNumberof trackstraversed27 73 110 10 64 36 64 36129 102 120 10 41 23 41 23 110 19 129 9 27 14 27 14 186 76 147 18 10 17 10 17 147 39 186 39 110 100 186 17641 106 64 122 120 10 147 3910 31 41 23 129 9 129 1864 54 27 14 147 18 120 9120 56 10 17 186 39 110 10 Average 61.8 Average 29.1 Average 29.6 Average 38If the disk head is initially moving in the direction of increasing tracknumber, only the SCAN and C-SCAN results change:SCAN C-SCANNext track accessed Numberof trackstraversedNexttrackaccessedNumberof trackstraversed110 10 110 10120 10 120 10129 9 129 9147 18 147 18186 39 186 3964 122 10 17641 23 27 1727 14 41 1410 17 64 23 Average 29.1 Average 35.1Review Questions12.1 A field is the basic element of data containing a single value. A recordis a collection of related fields that can be treated as a unit by some application program.12.5 Pile: Data are collected in the order in which they arrive. Each recordconsists of one burst of data. Sequential file: A fixed format is used for records. All records are of the same length, consisting of the same number of fixed-length fields in a particular order. Because the length and position of each field is known, only the values of fields need to be stored; the field name and length for each field are attributes of the file structure. Indexed sequential file: The indexed sequential file maintains the key characteristic of the sequential file: records are organized in sequence based on a key field. Two features are added; an index to the file to support random access, and an overflow file. The index provides a lookup capability to reach quickly the vicinity of a desired record. The overflow file is similar to the log file used with a sequential file, but is integrated so that records in the overflow file are located by following a pointer from their predecessor record. Indexed file: Records are accessed only through their indexes. The result is that there is now no restriction on the placement of records as long as a pointer in at least one index refers to that record. Furthermore,variable-length records can be employed. Direct, or hashed, file: The direct file makes use of hashing on the key value.Problems12.1 Fixed blocking: F = largest integer B RWhen records of variable length are packed into blocks, data formarking the record boundaries within the block has to be added to separate the records. When spanned records bridge block boundaries, some reference to the successor block is also needed. One possibility is a length indicator preceding each record. Another possibility is a special separator marker between records. In any case, we can assume that each record requires a marker, and we assume that the size of a marker is about equal to the size of a block pointer [WEID87]. For spanned blocking, a block pointer of size P to its successor block may C HAPTER 12F ILE M ANAGEMENTbe included in each block, so that the pieces of a spanned record can easily be retrieved. Then we haveVariable-length spanned blocking: F=B-P R+PWith unspanned variable-length blocking, an average of R/2 will be wasted because of the fitting problem, but no successor pointer is required:Variable-length unspanned blocking: F=B-R2 R+P12.3 a. Indexedb. Indexed sequentialc. Hashed or indexed。

操作系统——精髓与设计原理(第五章答案)

操作系统——精髓与设计原理(第五章答案)
hut(); • signal(returnreindeer)//释放驯鹿返回互斥信号量} • } • Kids i:{making toys; • wait(needhelp);//获得需要帮助信号量 • Kidscount++; • if elvescount==3 • signal(wakesanta);//释放唤醒圣诞 //老人信号量 • else signal(needhelp);//释放需要帮助互 //斥信号量 • }
• 5.9 • 错误情形:假设有2个进程都调用Wait且s的 初值为0。在第一个进程执行完 SignalB(mutex)且尚未执行WaitB(delay)时, 第二个进程开始调用Wait,也停在同一点 (即SignalB(mutex)和WaitB(delay)之间)。 这时,s的值为-2,而mutex是打开的。假如 有另外2个进程在这时相继调用了Signal, 那么他们每个都会做SignalB(delay)操作, 但程序中后一个SignalB将没有意义。
总述: • 当一个进程希望进入其临界区,它将得到 一张票,票的号码将是所有等待进入临界 区或已在临界区的进程所得到票的号码中 最大者加1。拥有最小票号的进程将率先进 入临界区。如果有多个进程得到的票具有 相同的号码,则进程号更小的进程将更占 优势。当一个进程离开其临界区,它将重 置其中票号为0。
• b.解释此算法如何避免死锁 • 死锁时的情形:每个人都拿到了顺序号,但 都拿不到面包。 • 在本算法中即使顺序号相同,但数组下标是 不同的。所以进程总可推进不会发生死锁。 • c.解释此算法如何加强互斥; • (1)对临界资源面包是按照顺序号互斥的使用 • (2)对number数组的操作通过写操作前置true 保证其它进程此时不能对其读,从而保证读 写互斥。

操作系统教程第5版部分习题标准答案

操作系统教程第5版部分习题标准答案

第一章:一、3、10、15、23、27、353.什么是操作系统?操作系统在计算机系统中的主要作用是什么?操作系统是管理系统资源、控制程序执行、改善人机界面、提供各种服务,并合理组织计算机工作流程和为用户有效地使用计算机提供良好运行环境的一种系统软件.主要作用(1)服务用户—操作系统作为用户接口和公共服务程序(2)进程交互—操作系统作为进程执行的控制者和协调者(3)系统实现—操作系统作为扩展机或虚拟机(4)资源管理—操作系统作为资源的管理者和控制者10.试述系统调用与函数(过程)调用之间的区别。

(1)调用形式和实现方式不同;(2)被调用的代码位置不同;(3)提供方式不同15.什么是多道程序设计?多道程序设计有什么特点?多道程序设计是指允许多个作业(程序)同时进入计算机系统内存并执行交替计算的方法。

从宏观上看是并行的,从微观上看是串行的。

(1)可以提高CPU、内存和设备的利用率;(2)可以提高系统的吞吐率,使单位时间内完成的作业数目增加;(3)可以充分发挥系统的并行性,使设备和设备之间,设备和CPU之间均可并行工作。

23.现代操作系统具有哪些基本功能?请简单叙述之。

(1)处理器管理;(2)存储管理;(3)设备管理;(4)文件管理;(5)联网与通信管理。

27.什么是操作系统的内核?内核是一组程序模块,作为可信软件来提供支持进程并发执行的基本功能和基本操作,通常驻留在内核空间,运行于内核态,具有直接访问计算机系统硬件设备和所有内存空间的权限,是仅有的能够执行特权指令的程序。

35.简述操作系统资源管理的资源复用技术。

系统中相应地有多个进程竞争使用资源,由于计算机系统的物理资源是宝贵和稀有的,操作系统让众多进程共享物理资源,这种共享称为资源复用。

(1)时分复用共享资源从时间上分割成更小的单位供进程使用;(2)空分复用共享资源从空间上分割成更小的单位供进程使用。

.二、2、52、答:画出两道程序并发执行图如下:(1)(见图中有色部分)。

操作系统一精髓与设计原理第五版选择题与答案英文版第一到第十一章

操作系统一精髓与设计原理第五版选择题与答案英文版第一到第十一章

操作系统一精髓与设计原理第五版选择题与答案英文版第一到第十一章第一章The general role of an operating system is to: da. None of the aboveb. Manage files for application programsc. Act as an interface between various computersd. Provide a set of services to system usersInformation that must be saved prior to the processor transferring control to theinterrupt handler routine includes:ba. None of the aboveb. Processor Status Word (PSW) & Location of next instructionc. Processor Status Word (PSW)d. Processor Status Word (PSW) & Contents of processor registersOne accepted method of dealing with multiple interrupts is to: 选择一个答案aa. Define priorities for the interruptsb. None of the abovec. Disable all interrupts except those of highest priorityd. Service them in round-robin fashionIn a uniprocessor system, multiprogramming increases processor efficiencyby:选择一个答案da. Increasing processor speedb. Eliminating all idle processor cyclesc. All of the aboved. Taking advantage of time wasted by long wait interrupt handlingAs one proceeds down the memory hierarchy (i.e., from inboard memory to offlinestorage), the following condition(s) apply: c选择一个答案a. Decreasing capacityb. Increasing cost per bitc. Increasing access timed. All of the aboveSmall, fast memory located between the processor and main memory is called 选择一个答案ba. None of the aboveb. Cache memoryc. WORM memoryd. CD-RW memoryWhen a new block of data is written into cache memory, the following determines whichcache location the block will occupy: 选择一个答案aa. None of the aboveb. Write policyc. Cache sized. Block sizeThe four main structural elements of a computer system are:选择一个答案ba. Processor, Registers, I/O Modules & Main Memoryb. Processor, Main Memory, I/O Modules & System Busc. None of the aboved. Processor, Registers, Main Memory & System BusThe two basic types of processor registers are:选择一个答案aa. User-visible and Control/Status registersb. User-visible and user-invisible registersc. None of the aboved. Control and Status registersAddress registers may contain选择一个答案ca. Memory addresses of datab. Memory addresses of instructionsc. All of the aboved. Partial memory addressesA Control/Status register that contains the address of the next instruction to be fetched iscalled the:选择一个答案ca. All of the aboveb. Program Status Word (PSW)c. Program Counter (PC)d. Instruction Register (IR)The two basic steps used by the processor in instruction processing are:选择一个答案ca. Instruction and Execute cyclesb. Fetch and Instruction cyclesc. Fetch and Execute cyclesd. None of the aboveA fetched instruction is normally loaded into the:选择一个答案ca. Program Counter (PC)b. None of the abovec. Instruction Register (IR)d. Accumulator (AC)A common class of interrupts is选择一个答案da. Programb. I/Oc. Timerd. All of the aboveWhen an external device becomes ready to be serviced by the processor, the devicesends this type of signal to the processor:选择一个答案ba. None of the aboveb. Interrupt signalc. Halt signald. Handler signal第二章A primary objective of an operating system is:选择一个答案aa. All of the aboveb. Conveniencec. Ability to evolved. EfficiencyThe paging system in a memory management system provides for dynamic mappingbetween a virtual address used in a program and:选择一个答案aa. A real address in main memoryb. None of the abovec. A virtual address in main memoryd. A real address in a programRelative to information protection and security in computer systems, accesscontrol typically refers to:选择一个答案da. Proving that security mechanisms perform according to specificationb. None of the abovec. The flow of data within the systemd. Regulating user and process access to various aspects of the systemA common problem with full-featured operating systems, due to their size anddifficulty of the tasks they address, is:选择一个答案da. Latent bugs that show up in the fieldb. Chronically late in deliveryc. Sub-par performanced. All of the aboveA technique in which a process, executing an application, is divided intothreads that can run concurrently is called:选择一个答案da. None of the aboveb. Symmetric multiprocessing (SMP)c. Multiprocessingd. MultithreadingWIN2K supports several types of user applications, including: 选择一个答案ca. None of the aboveb. Linuxc. WIN32d. System 10Key to the success of Linux has been it’s character as a free software packageavailable under the auspices of the:选择一个答案ca. None of the aboveb. Berkeley Software Distributionc. Free Software Foundationd. World Wide Web ConsortiumThe operating system provides many types of services to end-users, programmers andsystem designers, including:选择一个答案ba. Built-in user applicationsb. Error detection and responsec. All of the aboved. Relational database capabilities with the internal file systemThe operating system is unusual in it’s role as a control mechanism, in that:选择一个答案ca. None of the aboveb. It runs on a special processor, completely separated from therest of thesystemc. It frequently relinquishes control of the system processor and mustdepend on the processor to regain control of the systemd. It never relinquishes control of the system processorOperating systems must evolve over time because选择一个答案aa. New hardware is designed and implemented in the computer systemb. Hardware must be replaced when it failsc. All of the aboved. Users will only purchase software that has a current copyright dateA major problem with early serial processing systems was:选择一个答案aa. Setup timeb. Inability to get hardcopy outputc. All of the aboved. Lack of input devicesAn example of a hardware feature that is desirable in a batch-processingsystem is选择一个答案aa. Privileged instructionsb. None of the abovec. A completely accessible memory aread. Large clock cyclesA computer hardware feature that is vital to the effective operation of a multiprogrammingoperating system is:选择一个答案ba. All of the aboveb. I/O interrupts and DMAc. Very large memoryd. Multiple processorsThe principle objective of a time sharing, multiprogramming system is to 选择一个答案ca. Maximize processor useb. Maximize response timec. None of the aboved. Provide exclusive access to hardwareWhich of the following major line of computer system development created problems intiming and synchronization that contributed to the development of the concept of theprocess?选择一个答案ca. Multiprogramming batch operation systemsb. Real time transaction systemsc. All of the aboved. Time sharing systems第三章The behavior of a processor can be characterized by examining: 选择一个答案ba. Multiple process tracesb. The interleaving of the process tracesc. All of the aboved. A single process traceThe Process Image element that contains the modifiable part of the user space is calledthe:a进程镜像=PCB+程序+STACK+可修改的DATAa. None of the aboveb. Process Control Blockc. System Stackd. User Program分数: 7/7The processor execution mode that user programs typically execute in is referred to as:a选择一个答案a. User modeb. None of the abovec. Kernel moded. System modeOne step in the procedure for creating a new process involves:步骤:b选择一个答案a. Allocating space for the processb. All of the abovec. Initializing the process control blockd. Assigning a unique identifierA process switch may occur when the system encounters an interruptcondition, such as that generated by a: 进程切换:TRAP(异常)+系统调用 +INTERRUPT选择一个答案ca. Trapb. Supervisor callc. All of the aboved. Memory fault##操作系统仅仅是一组程序,并被处理器执行,是进程吗,如何控制它, 。

操作系统教程第5版部分习题答案

操作系统教程第5版部分习题答案

第一章:一、3、10、15、23、27、353.什么是操作系统?操作系统在计算机系统中的主要作用是什么?操作系统是管理系统资源、控制程序执行、改善人机界面、提供各种服务,并合理组织计算机工作流程和为用户有效地使用计算机提供良好运行环境的一种系统软件.主要作用(1)服务用户—操作系统作为用户接口和公共服务程序(2)进程交互—操作系统作为进程执行的控制者和协调者(3)系统实现—操作系统作为扩展机或虚拟机(4)资源管理—操作系统作为资源的管理者和控制者10.试述系统调用与函数(过程)调用之间的区别。

(1)调用形式和实现方式不同;(2)被调用的代码位置不同;(3)提供方式不同15.什么是多道程序设计?多道程序设计有什么特点?多道程序设计是指允许多个作业(程序)同时进入计算机系统内存并执行交替计算的方法。

从宏观上看是并行的,从微观上看是串行的。

(1)可以提高CPU、内存和设备的利用率;(2)可以提高系统的吞吐率,使单位时间内完成的作业数目增加;(3)可以充分发挥系统的并行性,使设备和设备之间,设备和CPU之间均可并行工作。

23.现代操作系统具有哪些基本功能?请简单叙述之。

(1)处理器管理;(2)存储管理;(3)设备管理;(4)文件管理;(5)联网与通信管理。

27.什么是操作系统的内核?内核是一组程序模块,作为可信软件来提供支持进程并发执行的基本功能和基本操作,通常驻留在内核空间,运行于内核态,具有直接访问计算机系统硬件设备和所有内存空间的权限,是仅有的能够执行特权指令的程序。

35.简述操作系统资源管理的资源复用技术。

系统中相应地有多个进程竞争使用资源,由于计算机系统的物理资源是宝贵和稀有的,操作系统让众多进程共享物理资源,这种共享称为资源复用。

(1)时分复用共享资源从时间上分割成更小的单位供进程使用;(2)空分复用共享资源从空间上分割成更小的单位供进程使用。

.二、2、52、答:画出两道程序并发执行图如下:(1)两道程序运行期间,CPU存在空闲等待,时间为100至150ms之间(见图中有色部分)。

操作系统一精髓与设计原理第五版选择题与答案英文版第一到第十一章

操作系统一精髓与设计原理第五版选择题与答案英文版第一到第十一章

第一章The general role of an operating system is to:da. None of the aboveb. Manage files for application programsc. Act as an interface between various computersd. Provide a set of services to system usersInformation that must be saved prior to the processor transferring control to the interrupt handler routine includes:ba. None of the aboveb. Processor Status Word (PSW) & Location of next instructionc. Processor Status Word (PSW)d. Processor Status Word (PSW) & Contents of processor registersOne accepted method of dealing with multiple interrupts is to:选择一个答案aa. Define priorities for the interruptsb. None of the abovec. Disable all interrupts except those of highest priorityd. Service them in round-robin fashionIn a uniprocessor system, multiprogramming increases processor efficiency by:选择一个答案da. Increasing processor speedb. Eliminating all idle processor cyclesc. All of the aboved. Taking advantage of time wasted by long wait interrupt handlingAs one proceeds down the memory hierarchy (i.e., from inboard memory to offline storage), the following condition(s) apply:c选择一个答案a. Decreasing capacityb. Increasing cost per bitc. Increasing access timed. All of the aboveSmall, fast memory located between the processor and main memory is called选择一个答案ba. None of the aboveb. Cache memoryc. WORM memoryd. CD-RW memoryWhen a new block of data is written into cache memory, the following determines which cache location the block will occupy:选择一个答案aa. None of the aboveb. Write policyc. Cache sized. Block sizeThe four main structural elements of a computer system are:选择一个答案ba. Processor, Registers, I/O Modules & Main Memoryb. Processor, Main Memory, I/O Modules & System Busc. None of the aboved. Processor, Registers, Main Memory & System BusThe two basic types of processor registers are:选择一个答案aa. User-visible and Control/Status registersb. User-visible and user-invisible registersc. None of the aboved. Control and Status registersAddress registers may contain选择一个答案ca. Memory addresses of datab. Memory addresses of instructionsc. All of the aboved. Partial memory addressesA Control/Status register that contains the address of the next instruction to be fetched is called the:选择一个答案ca. All of the aboveb. Program Status Word (PSW)c. Program Counter (PC)d. Instruction Register (IR)The two basic steps used by the processor in instruction processing are:选择一个答案ca. Instruction and Execute cyclesb. Fetch and Instruction cyclesc. Fetch and Execute cyclesd. None of the aboveA fetched instruction is normally loaded into the:选择一个答案ca. Program Counter (PC)b. None of the abovec. Instruction Register (IR)d. Accumulator (AC)A common class of interrupts is选择一个答案da. Programb. I/Oc. Timerd. All of the aboveWhen an external device becomes ready to be serviced by the processor, the device sends this type of signal to the processor:选择一个答案ba. None of the aboveb. Interrupt signalc. Halt signald. Handler signal第二章A primary objective of an operating system is:选择一个答案aa. All of the aboveb. Conveniencec. Ability to evolved. EfficiencyThe paging system in a memory management system provides for dynamic mapping between a virtual address used in a program and:选择一个答案aa. A real address in main memoryb. None of the abovec. A virtual address in main memoryd. A real address in a programRelative to information protection and security in computer systems, access control typically refers to:选择一个答案da. Proving that security mechanisms perform according to specificationb. None of the abovec. The flow of data within the systemd. Regulating user and process access to various aspects of the systemA common problem with full-featured operating systems, due to their size and difficulty of the tasks they address, is:选择一个答案da. Latent bugs that show up in the fieldb. Chronically late in deliveryc. Sub-par performanced. All of the aboveA technique in which a process, executing an application, is divided into threads that can run concurrently is called:选择一个答案da. None of the aboveb. Symmetric multiprocessing (SMP)c. Multiprocessingd. MultithreadingWIN2K supports several types of user applications, including:选择一个答案ca. None of the aboveb. Linuxc. WIN32d. System 10Key to the success of Linux has been it’s character as a free software package available under the auspices of the:选择一个答案ca. None of the aboveb. Berkeley Software Distributionc. Free Software Foundationd. World Wide Web ConsortiumThe operating system provides many types of services to end-users, programmers and system designers, including:选择一个答案ba. Built-in user applicationsb. Error detection and responsec. All of the aboved. Relational database capabilities with the internal file systemThe operating system is unusual in it’s role as a control mechanism, in that:选择一个答案ca. None of the aboveb. It runs on a special processor, completely separated from the rest of thesystemc. It frequently relinquishes control of the system processor and mustdepend on the processor to regain control of the systemd. It never relinquishes control of the system processorOperating systems must evolve over time because选择一个答案aa. New hardware is designed and implemented in the computer systemb. Hardware must be replaced when it failsc. All of the aboved. Users will only purchase software that has a current copyright dateA major problem with early serial processing systems was:选择一个答案aa. Setup timeb. Inability to get hardcopy outputc. All of the aboved. Lack of input devicesAn example of a hardware feature that is desirable in a batch-processing system is选择一个答案aa. Privileged instructionsb. None of the abovec. A completely accessible memory aread. Large clock cyclesA computer hardware feature that is vital to the effective operation of a multiprogramming operating system is:选择一个答案ba. All of the aboveb. I/O interrupts and DMAc. Very large memoryd. Multiple processorsThe principle objective of a time sharing, multiprogramming system is to选择一个答案ca. Maximize processor useb. Maximize response timec. None of the aboved. Provide exclusive access to hardwareWhich of the following major line of computer system development created problems in timing and synchronization that contributed to the development of the concept of the process?选择一个答案ca. Multiprogramming batch operation systemsb. Real time transaction systemsc. All of the aboved. Time sharing systems第三章The behavior of a processor can be characterized by examining:选择一个答案ba. Multiple process tracesb. The interleaving of the process tracesc. All of the aboved. A single process traceThe Process Image element that contains the modifiable part of the user space is called the:a进程镜像=PCB+程序+STACK+可修改的DATAa. None of the aboveb. Process Control Blockc. System Stackd. User Program分数: 7/7The processor execution mode that user programs typically execute in is referred to as: a选择一个答案a. User modeb. None of the abovec. Kernel moded. System modeOne step in the procedure for creating a new process involves:步骤:b选择一个答案a. Allocating space for the processb. All of the abovec. Initializing the process control blockd. Assigning a unique identifierA process switch may occur when the system encounters an interrupt condition, such as that generated by a:进程切换:TRAP(异常)+系统调用+INTERRUPT选择一个答案ca. Trapb. Supervisor callc. All of the aboved. Memory fault##操作系统仅仅是一组程序,并被处理器执行,是进程吗?如何控制它?。

操作系统教程第5版部分习题答案

操作系统教程第5版部分习题答案

第一章:一、3、10、15、23、27、353.什么是操作系统操作系统在计算机系统中的主要作用是什么操作系统是管理系统资源、控制程序执行、改善人机界面、提供各种服务,并合理组织计算机工作流程和为用户有效地使用计算机提供良好运行环境的一种系统软件.主要作用(1)服务用户—操作系统作为用户接口和公共服务程序(2)进程交互—操作系统作为进程执行的控制者和协调者(3)系统实现—操作系统作为扩展机或虚拟机(4)资源管理—操作系统作为资源的管理者和控制者10.试述系统调用与函数(过程)调用之间的区别。

(1)调用形式和实现方式不同;(2)被调用的代码位置不同;(3)提供方式不同15.什么是多道程序设计多道程序设计有什么特点多道程序设计是指允许多个作业(程序)同时进入计算机系统内存并执行交替计算的方法。

从宏观上看是并行的,从微观上看是串行的。

(1)可以提高CPU、内存和设备的利用率;(2)可以提高系统的吞吐率,使单位时间内完成的作业数目增加;(3)可以充分发挥系统的并行性,使设备和设备之间,设备和CPU之间均可并行工作。

23.现代操作系统具有哪些基本功能请简单叙述之。

(1)处理器管理;(2)存储管理;(3)设备管理;(4)文件管理;(5)联网与通信管理。

27.什么是操作系统的内核内核是一组程序模块,作为可信软件来提供支持进程并发执行的基本功能和基本操作,通常驻留在内核空间,运行于内核态,具有直接访问计算机系统硬件设备和所有内存空间的权限,是仅有的能够执行特权指令的程序。

35.简述操作系统资源管理的资源复用技术。

系统中相应地有多个进程竞争使用资源,由于计算机系统的物理资源是宝贵和稀有的,操作系统让众多进程共享物理资源,这种共享称为资源复用。

(1)时分复用共享资源从时间上分割成更小的单位供进程使用;(2)空分复用共享资源从空间上分割成更小的单位供进程使用。

.二、2、52、答:画出两道程序并发执行图如下:(1)两道程序运行期间,CPU存在空闲等待,时间为100至150ms之间(见图中有色部分)。

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

第1章计算机系统概述1.1、图1.3中的理想机器还有两条I/O指令:0011 = 从I/O中载入AC0111 = 把AC保存到I/O中在这种情况下,12位地址标识一个特殊的外部设备。

请给出以下程序的执行过程(按照图1.4的格式):1.从设备5中载入AC。

2.加上存储器单元940的内容。

3.把AC保存到设备6中。

假设从设备5中取到的下一个值为3940单元中的值为2。

答案:存储器(16进制内容):300:3005;301:5940;302:7006步骤1:3005->IR;步骤2:3->AC步骤3:5940->IR;步骤4:3+2=5->AC步骤5:7006->IR:步骤6:AC->设备61.2、本章中用6步来描述图1.4中的程序执行情况,请使用MAR和MBR扩充这个描述。

答案:1. a. PC中包含第一条指令的地址300,该指令的内容被送入MAR中。

b. 地址为300的指令的内容(值为十六进制数1940)被送入MBR,并且PC增1。

这两个步骤是并行完成的。

c. MBR中的值被送入指令寄存器IR中。

2. a. 指令寄存器IR中的地址部分(940)被送入MAR中。

b. 地址940中的值被送入MBR中。

c. MBR中的值被送入AC中。

3. a. PC中的值(301)被送入MAR中。

b. 地址为301的指令的内容(值为十六进制数5941)被送入MBR,并且PC增1。

c. MBR中的值被送入指令寄存器IR中。

4. a. 指令寄存器IR中的地址部分(941)被送入MAR中。

b. 地址941中的值被送入MBR中。

c. AC中以前的内容和地址为941的存储单元中的内容相加,结果保存到AC中。

5. a. PC中的值(302)被送入MAR中。

b. 地址为302的指令的内容(值为十六进制数2941)被送入MBR,并且PC增1。

c. MBR中的值被送入指令寄存器IR中。

6. a. 指令寄存器IR中的地址部分(941)被送入MAR中。

b. AC中的值被送入MBR中。

c. MBR中的值被存储到地址为941的存储单元之中。

1.4、假设有一个微处理器产生一个16位的地址(例如,假设程序计数器和地址寄存器都是16位)并且具有一个16位的数据总线。

a.如果连接到一个16位存储器上,处理器能够直接访问的最大存储器地址空间为多少?b.如果连接到一个8位存储器上,处理器能够直接访问的最大存储器地址空间为多少?c.处理访问一个独立的I/O空间需要哪些结构特征?d.如果输入指令和输出指令可以表示8位I/O端口号,这个微处理器可以支持多少8位I/O端口?答案:对于(a)和(b)两种情况,微处理器可以直接访问的最大存储器地址空间为216 = 64K bytes;唯一的区别是8位存储器每次访问传输1个字节,而16位存储器每次访问可以传输一个字节或者一个16位的字。

对于(c)情况,特殊的输入和输出指令是必要的,这些指令的执行体会产生特殊的“I/O信号”(有别于“存储器信号”,这些信号由存储器类型指令的执行体产生);在最小状态下,一个附加的输出针脚将用来传输新的信号。

对于(d)情况,它支持28 = 256个输入和28 = 256个输出字节端口和相同数目的16位I/O端口;在任一情况,一个输入和一个输出端口之间的区别是通过被执行的输入输出指令所产生的不同信号来定义的。

1.5、考虑一个32位微处理器,它有一个16位外部数据总线,并由一个8MHz的输入时钟驱动。

假设这个微处理器有一个总线周期,其最大持续时间等于4个输入时钟周期。

请问该微处理器可以支持的最大数据传送速度为多少?外部数据总线增加到21位,或者外部时钟频率加倍,哪种措施可以更好地提高处理器性能?请叙述你的设想并解释原因。

答案:时钟周期=1/(8MHZ)=125ns总线周期=4×125ns=500ns每500ns传输2比特;因此传输速度=4MB/s加倍频率可能意味着采用了新的芯片制造技术(假设每个指令都有相同的时钟周期数);加倍外部数据总线,在芯片数据总线驱动/锁存、总线控制逻辑的修改等方面手段广泛(或许更新)。

在第一种方案中,内存芯片的速度要提高一倍(大约),而不能降低微处理器的速度;第二种方案中,内存的字长必须加倍,以便能发送/接受32位数量。

1.6、考虑一个计算机系统,它包含一个I/O模块,用以控制一台简单的键盘/打印机电传打字设备。

CPU 中包含下列寄存器,这些寄存器直接连接到系统总线上:INPR:输入寄存器,8位OUTR:输出寄存器,8位FGI:输入标记,1位FGO:输出标记,1位IEN:中断允许,1位I/O模块控制从打字机中输入击键,并输出到打印机中去。

打字机可以把一个字母数字符号编码成一个8位字,也可以把一个8位字解码成一个字母数字符号。

当8位字从打字机进入输入寄存器时,输入标记被置位;当打印一个字时,输出标记被置位。

a.描述CPU如何使用这4个寄存器实现与打字机间的输入/输出。

b.描述通过使用IEN,如何提高执行效率?答案:a.来源于打字机的输入储存在INPR中。

只有当FGI=0时,INPR才会接收来自打字机的数据。

当数据接收后,被储存在INPR里面,同时FGI置为1。

CPU定期检查FGI。

如果FGI=1,CPU将把INPR里面的内容传送至AC,并把FGI置为0。

当CPU需要传送数据到打字机时,它会检查FGO。

如果FGO=0,CPU处于等待。

如果FGO =1,CPU将把AC的内容传送至OUTER并把FGO置为0。

当数字符号打印后,打字机将把FGI 置为1。

b.(A)描述的过程非常浪费。

速度远高于打字机的CPU必须反复不断的检查FGI和FGO。

如果中断被使用,当打字机准备接收或者发送数据时,可以向CPU发出一个中断请求。

IEN计数器可以由CPU设置(在程序员的控制下)。

1.7、实际上在所有包括DMA模块的系统中,DMA访问主存储器的优先级总是高于处理器访问主存储器的优先级。

这是为什么?答案:如果一个处理器在尝试着读或者写存储器时被挂起, 通常除了一点轻微的时间损耗之外没有任何危害。

但是,DMA可能从或者向设备(例如磁盘或磁带)以数据流的方式接收或者传输数据并且这是不能被打断的。

否则,如果DMA设备被挂起(拒绝继续访问主存),数据可能会丢失。

1.9、一台计算机包括一个CPU和一台I/O设备D,通过一条共享总线连接到主存储器M,数据总线的宽度为1个字。

CPU每秒最多可执行106条指令,平均每条指令需要5个机器周期,其中3个周期需要使用存储器总线。

存储器读/写操作使用1个机器周期。

假设CPU正在连续不断地执行后台程序,并且需要保证95%的指令执行速度,但没有任何I/O指令。

假设1个处理器周期等于1个总线周期,现在要在M和D 之间传送大块数据。

a.若使用程序控制I/O,I/O每传送1个字需要CPU执行两条指令。

请估计通过D的I/O数据传送的最大可能速度。

b.如果使用DMA 传送,请估计传送速度。

答案:a.处理器只能分配5%的时间给I/O.所以最大的I/O 指令传送速度是10e6×0.05=50000条指令/秒。

因此I/O 的传送速率是25000字/秒。

b.使用DMA 控制时,可用的机器周期下的数量是10e6(0.05×5+0.95×2)=2.15×10e6如果我们假设DMA 模块可以使用所有这些周期,并且忽略任何设置和状态检查时间,那么这个值就是最大的I/O 传输速率。

1.10、考虑以下代码:for ( i = 0;i < 20;i++)for (j = 0;j < 10;j++)a[i] = a[i]*ja. 请举例说明代码中的空间局部性。

b. 请举例说明代码中的时间局部性。

答案:a.读取第二条指令是紧跟着读取第一条指令的。

b.在很短的间歇时间内, a[i]在循环内部被访问了十次。

1.11、请将附录1A 中的式(1.1)和式(1.2)推广到n 级存储器层次中。

答案:定义:C i = 存储器层次i 上每一位的存储单元平均花销S i = 存储器层次i 的规模大小T i = 存储器层次i 上访问一个字所需时间H i = 一个字在不高于层次i 的存储器上的概率B i = 把一个数据块从层次i+1的存储器上传输到层次i 的存储器上所需时间高速缓冲存储器作为是存储器层次1;主存为存储器层次2;针对所有的N 层存储器层以此类推。

有:11n ii i S n i i C S C S===∑∑T s 的引用更复杂,我们从概率论入手:所期望的值1Pr[1]ni x i x ===∑,由此我们可以写出:1n s i i i T T H ==∑我们需要清楚如果一个字在M1(缓存)中,那么对它的读取非常快。

如果这个字在M2而不在M1中,那么数据块需要从M2传输到M1中,然后才能读取。

因此,T 2 = B 1+T 1进一步,T 3 = B 2+T 2 = B 1+B 2+T 1以此类推:111i i j j T BT -==+∑所以,11211()n i n s j i i i j i T B H T H -====+∑∑∑但是,11n i i H==∑最后,1121()n i s i i i j T B H T -===+∑∑ 1.12、考虑一个存储器系统,它具有以下参数:T c = 100 ns C c = 0.01 分/位T m = 1200 ns C m = 0.001 分/位a.1MB 的主存储器价格为多少?b.使用高速缓冲存储器技术,1MB 的主存储器价格为多少?c.如果有效存取时间比高速缓冲存储器存取时间多10% ,命中率H 为多少?答案:a.价格 = C m ×8×106 = 8×103 ¢ = $80b.价格 = Cc×8×106 = 8×104 ¢ = $800c.由等式1.1知:1.1×T 1 = T 1+(1-H)T 2(0.1)(100) = (1-H)(1200)H=1190/12001.13、一台计算机包括包括高速缓冲存储器、主存储器和一个用做虚拟存储器的磁盘。

如果要存取的字在高速缓冲存储器中,存取它需要20ns;如果该字在主存储器中而不在高速缓冲存储器中,把它载入高速缓冲存储器需要60ns(包括最初检查高速缓冲存储器的时间),然后再重新开始存取;如果该字不在主存储器中,从磁盘中取到内存需要12ms,接着复制到高速缓冲存储器中还需要60ns,再重新开始存取。

高速缓冲存储器的命中率为0.9,主存储器的命中率为0.6,则该系统中存取一个字的平均存取时间是多少(单位为ns)?答案:有三种情况需要考虑:所以平均访问时间是:Avg = (0.9)(20) + (0.06)(80) + (0.04)(12000080) = 480026 ns1.14、假设处理器使用一个栈来管理过程调用和返回。

相关文档
最新文档