操作系统教程第5版课后标准答案
- 格式:docx
- 大小:98.81 KB
- 文档页数:7
精品文档虚拟内存8.1 简单分页与虚拟分页有什么区别?简单分页:一个程序中的所有的页都必须在主存储器中程序才能正常运行,除非使用覆盖技术。
虚拟内存分页:不是程序的每一页都必须在主存储器的帧中来使程序运行,页在需要的时候进行读取。
8.2 解释什么是抖动。
虚拟内存结构的震动现象,在这个过程中处理器大部分的时间都用于交换块,而不是执行指令。
8.3 为什么在使用虚拟内存时,局部性原理是至关重要的?可以根据局部性原理设计算法来避免抖动。
总的来说,局部性原理允许算法预测哪一个当前页在最近的未来是最少可能被使用的,并由此就决定候选的替换出的页。
8.4 哪些元素是页表项中可以找到的元素?简单定义每个元素。
帧号:用来表示主存中的页来按顺序排列的号码。
存在位(P):表示这一页是否当前在主存中。
修改位(M):表示这一页在放进主存后是否被修改过。
8.5 转移后备缓冲器的目的是什么?转移后备缓冲器(TLB)是一个包含最近经常被使用过的页表项的高速缓冲存储器。
它的目的是为了减少从磁盘中恢复一个页表项所需的时间。
8.6 简单定义两种可供选择的页读取策略。
在请求式分页中,只有当访问到某页中的一个单元时才将该页取入主存。
在预约式分页中,读取的并不是页错误请求的页。
8.7 驻留集管理和页替换策略有什么区别?驻留集管理主要关注以下两个问题:(1)给每个活动进程分配多少个页帧。
(2)被考虑替换的页集是仅限在引起页错误的进程的驻留集中选择还是在主存中所有的页帧中选择。
页替换策略关注的是以下问题:在考虑的页集中,哪一个特殊的页应该被选择替换。
8.8 FIFO和Clock页替换算法有什么区别?时钟算法与FIFO算法很接近,除了在时钟算法中,任何一个使用位为一的页被忽略。
8.9 页缓冲实现的是什么?(1)被替换出驻留集的页不久又被访问到时,仍在主存中,减少了一次磁盘读写。
(2)被修改的页以簇的方式被写回,而不是一次只写一个,这就大大减少了I/O操作的数目,从而减少了磁盘访问的时间。
《操作系统精髓与设计原理·第五版》练习题及答案第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。
•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 系统和用户进程的创建和删除:在系统中进程对于信息共享,加速计算,模块性和便利性都能并发执行。
并发的执行需要进程的创建和删除机制。
进程所需要的资源在进程被创建时获得或者在其运行的时候分配。
当进程结束时,操作系统需要收回任何可重用资源。
•进程的挂起和恢复:在进程调度中,当进程在等待某些资源时,操作系统需要把进程状态改变成等待或者就绪状态。
当进程所要求的资源可用时,操作系统需要把它的状态变为运行状态恢复它的执行。
•进程同步机制:协调进程分享数据。
并发访问使用共享数据可能导致数据不一致性,操作系统不得不为其提供一种进程同步机制用来确保协作进程有序的实行,从而保证数据的一致性。
•进程通信机制:在操作系统下执行的进程要么是独立的进程要么是协作的进程。
协作进程必须使用某些方法来实现进程间的通信。
第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中。
第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。
虚拟内存8.1 简单分页与虚拟分页有什么区别?简单分页:一个程序中的所有的页都必须在主存储器中程序才能正常运行,除非使用覆盖技术。
虚拟内存分页:不是程序的每一页都必须在主存储器的帧中来使程序运行,页在需要的时候进行读取。
8.2 解释什么是抖动。
虚拟内存结构的震动现象,在这个过程中处理器大部分的时间都用于交换块,而不是执行指令。
8.3 为什么在使用虚拟内存时,局部性原理是至关重要的?可以根据局部性原理设计算法来避免抖动。
总的来说,局部性原理允许算法预测哪一个当前页在最近的未来是最少可能被使用的,并由此就决定候选的替换出的页。
8.4 哪些元素是页表项中可以找到的元素?简单定义每个元素。
帧号:用来表示主存中的页来按顺序排列的号码。
存在位(P):表示这一页是否当前在主存中。
修改位(M):表示这一页在放进主存后是否被修改过。
8.5 转移后备缓冲器的目的是什么?转移后备缓冲器(TLB)是一个包含最近经常被使用过的页表项的高速缓冲存储器。
它的目的是为了减少从磁盘中恢复一个页表项所需的时间。
8.6 简单定义两种可供选择的页读取策略。
在请求式分页中,只有当访问到某页中的一个单元时才将该页取入主存。
在预约式分页中,读取的并不是页错误请求的页。
8.7 驻留集管理和页替换策略有什么区别?驻留集管理主要关注以下两个问题:(1)给每个活动进程分配多少个页帧。
(2)被考虑替换的页集是仅限在引起页错误的进程的驻留集中选择还是在主存中所有的页帧中选择。
页替换策略关注的是以下问题:在考虑的页集中,哪一个特殊的页应该被选择替换。
8.8 FIFO和Clock页替换算法有什么区别?时钟算法与FIFO算法很接近,除了在时钟算法中,任何一个使用位为一的页被忽略。
8.9 页缓冲实现的是什么?(1)被替换出驻留集的页不久又被访问到时,仍在主存中,减少了一次磁盘读写。
(2)被修改的页以簇的方式被写回,而不是一次只写一个,这就大大减少了I/O操作的数目,从而减少了磁盘访问的时间。
操作系统教程课后习题参考答案习题一习题二习题三习题四习题五习题六习题一1.设计操作系统的主要目的是什么?设计操作系统的目的是:(1)从系统管理人员的观点来看,设计操作系统是为了合理地去组织计算机工作流程,管理和分配计算机系统硬件及软件资源,使之能为多个用户所共享。
因此,操作系统是计算机资源的管理者。
(2)从用户的观点来看,设计操作系统是为了给用户使用计算机提供一个良好的界面,以使用户无需了解许多有关硬件和系统软件的细节,就能方便灵活地使用计算机。
2.操作系统的作用可表现在哪几个方面?(1) 方便用户使用:操作系统通过提供用户与计算机之间的友好界面来方便用户使用。
(2) 扩展机器功能:操作系统通过扩充硬件功能和提供新的服务来扩展机器功能。
(3) 管理系统资源:操作系统有效地管理系统中的所有硬件和软件资源,使之得到充分利用。
(4) 提高系统效率:操作系统合理组织计算机的工作流程,以改进系统性能和提高系统效率。
(5)构筑开放环境:操作系统遵循国际标准来设计和构造一个开放环境。
其含义主要是指:遵循有关国际工业标准和开放系统标准,支持体系结构的可伸缩性和可扩展性;支持应用程序在不同平台上的可移植性和互操作性。
3.试叙述脱机批处理和联机批处理工作过程(1)联机批处理工作过程用户上机前,需向机房的操作员提交程序、数据和一个作业说明书,后者提供了用户标识、用户想使用的编译程序以及所需的系统资源等基本信息。
这些资料必须变成穿孔信息,(例如穿成卡片的形式),操作员把各用户提交的一批作业装到输入设备上(若输入设备是读卡机,则该批作业是一叠卡片),然后由监督程序控制送到磁带上。
之后,监督程序自动输入第一个作业的说明记录,若系统资源能满足其要求,则将该作业的程序、数据调入主存,并从磁带上调入所需要的编译程序。
编译程序将用户源程序翻译成目标代码,然后由连接装配程序把编译后的目标代码及所需的子程序装配成一个可执行的程序,接着启动执行。
第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中。
操作系统罗宇版课后习题答案部分————————————————————————————————作者:————————————————————————————————日期:1。
2 操作系统以什么方式组织用户使用计算机?答:操作系统以进程的方式组织用户使用计算机.用户所需完成的各种任务必须由相应的程序来表达出来。
为了实现用户的任务,必须让相应功能的程序执行。
而进程就是指程序的运行,操作系统的进程调度程序决定CPU在各进程间的切换。
操作系统为用户提供进程创建和结束等的系统调用功能,使用户能够创建新进程.操作系统在初始化后,会为每个可能的系统用户创建第一个用户进程,用户的其他进程则可以由母进程通过“进程创建”系统调用进行创建。
1.4 早期监督程序(Monitor)的功能是什么?答:早期监督程序的功能是代替系统操作员的部分工作,自动控制作业的运行。
监督程序首先把第一道作业调入主存,并启动该作业。
运行结束后,再把下一道作业调入主存启动运行。
它如同一个系统操作员,负责批作业的I/O,并自动根据作业控制说明书以单道串行的方式控制作业运行,同时在程序运行过程中通过提供各种系统调用,控制使用计算机资源。
1。
7 试述多道程序设计技术的基本思想。
为什么采用多道程序设计技术可以提高资源利用率?答:多道程序设计技术的基本思想是,在主存同时保持多道程序,主机以交替的方式同时处理多道程序。
从宏观上看,主机内同时保持和处理若干道已开始运行但尚未结束的程序。
从微观上看,某一时刻处理机只运行某道程序。
可以提高资源利用率的原因:由于任何一道作业的运行总是交替地串行使用CPU、外设等资源,即使用一段时间的CPU,然后使用一段时间的I/O设备,由于采用多道程序设计技术,加之对多道程序实施合理的运行调度,则可以实现CPU和I/O设备的高度并行,可以大大提高CPU与外设的利用率.1。
8 什么是分时系统?其主要特征是什么?适用于哪些应用?答:分时系统是以多道程序设计技术为基础的交互式系统,在此系统中,一台计算机与多台终端相连接,用户通过各自的终端和终端命令以交互的方式使用计算机系统。
操作系统教程课后习题参考答案习题一习题二习题三习题四习题五习题六习题一1.设计操作系统的主要目的是什么?设计操作系统的目的是:(1)从系统管理人员的观点来看,设计操作系统是为了合理地去组织计算机工作流程,管理和分配计算机系统硬件及软件资源,使之能为多个用户所共享。
因此,操作系统是计算机资源的管理者。
(2)从用户的观点来看,设计操作系统是为了给用户使用计算机提供一个良好的界面,以使用户无需了解许多有关硬件和系统软件的细节,就能方便灵活地使用计算机。
2.操作系统的作用可表现在哪几个方面?(1) 方便用户使用:操作系统通过提供用户与计算机之间的友好界面来方便用户使用。
(2) 扩展机器功能:操作系统通过扩充硬件功能和提供新的服务来扩展机器功能。
(3) 管理系统资源:操作系统有效地管理系统中的所有硬件和软件资源,使之得到充分利用。
(4) 提高系统效率:操作系统合理组织计算机的工作流程,以改进系统性能和提高系统效率。
(5)构筑开放环境:操作系统遵循国际标准来设计和构造一个开放环境。
其含义主要是指:遵循有关国际工业标准和开放系统标准,支持体系结构的可伸缩性和可扩展性;支持应用程序在不同平台上的可移植性和互操作性。
3.试叙述脱机批处理和联机批处理工作过程(1)联机批处理工作过程用户上机前,需向机房的操作员提交程序、数据和一个作业说明书,后者提供了用户标识、用户想使用的编译程序以及所需的系统资源等基本信息。
这些资料必须变成穿孔信息,(例如穿成卡片的形式),操作员把各用户提交的一批作业装到输入设备上(若输入设备是读卡机,则该批作业是一叠卡片),然后由监督程序控制送到磁带上。
之后,监督程序自动输入第一个作业的说明记录,若系统资源能满足其要求,则将该作业的程序、数据调入主存,并从磁带上调入所需要的编译程序。
编译程序将用户源程序翻译成目标代码,然后由连接装配程序把编译后的目标代码及所需的子程序装配成一个可执行的程序,接着启动执行。
操作系统精髓与设计原理(第5版)课后习题答案第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中。
第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中。
操作系统课后习题答案第一章o引论1.设计现代OS的主要目标是什么方便性,有效性,可扩充性和开放性.2.OS的作用可表现为哪几个方面a.OS作为用户与计算机硬件系统之间的接口;b.OS作为计算机系统资源的管理者;c.OS作为扩充机器.4.试说明推动多道批处理系统形成和发展的主要动力是什么不断提高计算机资源利用率和系统吞吐量的需要;5.何谓脱机I/O和联机I/Oa.脱机输入输出方式(Off-LineI/O)是为了解决人机矛盾及CPU和I/O设备之间速度不匹配而提出的.它减少了CPU的空闲等待时间,提高了I/O速度.具体内容是将用户程序和数据在一台外围机的控制下,预先从低速输入设备输入到磁带上,当CPU需要这些程序和数据时,在直接从磁带机高速输入到内存,从而大大加快了程序的输入过程,减少了CPU等待输入的时间,这就是脱机输入技术;当程序运行完毕或告一段落,CPU需要输出时,无需直接把计算结果送至低速输出设备,而是高速把结果输出到磁带上,然后在外围机的控制下,把磁带上的计算结果由相应的输出设备输出,这就是脱机输出技术.b.若这种输入输出操作在主机控制下进行则称之为联机输入输出方式.6.试说明推动分时系统形成和发展的主要动力是什么用户的需要.即对用户来说,更好的满足了人-机交互,共享主机以及便于用户上机的需求.7.实现分时系统的关键问题是什么应如何解决a.关键问题:及时接收,及时处理;b.对于及时接收,只需在系统中设置一多路卡,多路卡作用是使主机能同时接收用户从各个终端上输入的数据;---对于及时处理,应使所有的用户作业都直接进入内存,在不长的时间内,能使每个作业都运行一次.8为什么要引入实时操作系统更好地满足实时控制领域和实时信息处理领域的需要.12试从交互性,及时性和可靠性方面,将分时系统与实时系统进行比较.a.分时系统是一种通用系统,主要用于运行终端用户程序,因而它具有较强的交互能力;而实时系统虽然也有交互能力,但其交互能力不及前者.b.实时信息系统对实用性的要求与分时系统类似,都是以人所能接收的等待时间来确定;而实时控制系统的及时性则是以控制对象所要求的开始截止时间和完成截止时间来确定的.c.实时系统对系统的可靠性要求要比分时系统对系统的可靠性要求高.13OS具有哪几大特征它的最基本特征是什么a.并发(Concurrence),共享(Sharing),虚拟(Virtual),异步性(Aynchronim).b.其中最基本特征是并发和共享.14处理机管理具有哪些功能它们的主要任务是什么a.进程控制,进程同步,进程通信和调度.b.进程控制的主要任务是为作业创建进程,撤销已结束的进程,以及控制进程在运行过程中的状态转换.---进程同步的主要任务是对诸进程的运行进行调节.---进程通信的任务是实现在相互合作进程之间的信息交换.---调度分为作业调度和进程调度.作业调度的基本任务是从后备队列中按照一定的算法,选择出若干个作业,为它们分配必要的资源;而进程调度的任务是从进程的就绪队列中,按照一定的算法选出一新进程,把处理机分配给它,并为它设置运行现场,是进程投入运行.15内存管理有哪些主要功能它们的主要任务是什么a.主要功能:内存分配,内存保护,地址映射和内存扩充等.b.内存分配的主要任务是为每道程序分配内存空间,提高存储器利用率,以减少不可用的内存空间,允许正在运行的程序申请附加的内存空间,以适应程序和数据动态增长的需要.---内存保护的主要任务是确保每道用户程序都在自己的内存空间中运行,互不干扰.---地址映射的主要任务是将地址空间中的逻辑地址转换为内存空间中与之对应的物理地址.---内存扩充的主要任务是借助虚拟存储技术,从逻辑上去扩充内存容量.16设备管理有哪些主要功能其主要任务是什么a.主要功能:缓冲管理,设备分配和设备处理,以及虚拟设备等.b.主要任务:完成用户提出的I/O请求,为用户分配I/O设备;提高CPU和I/O设备的利用率;提高I/O速度;以及方便用户使用I/O设备.17文件管理有哪些主要功能其主要任务是什么a.主要功能:对文件存储空间的管理,目录管理,文件的读,写管理以及文件的共享和保护.b.主要任务:对用户文件和系统文件进行管理,以方便用户使用,并保证文件的安全性.18是什么原因使操作系统具有异步性特征a.程序执行结果是不确定的,即程序是不可再现的.b.每个程序在何时执行,多个程序间的执行顺序以及完成每道程序所需的时间都是不确定的,即不可预知性.第二章2.试画出下面条语句的前趋图:S1:a=5-某;S2:b=a某某;S3:c=4某某;S4:d=b+c;S5:e=d+3.S1->S2->S4->S5......../......S33.程序并发执行为什么会产生间断性因为程序在并发执行过程中存在相互制约性.4.程序并发执行为什么会失去封闭性和可再现性因为程序并发执行时,多个程序共享系统中的各种资源,资源状态需要多个程序来改变,即存在资源共享性使程序失去封闭性;而失去了封闭性导致程序失去可再现性.5.在操作系统中为什么要引入进程概念它会产生什么样的影响为了使程序在多道程序环境下能并发执行,并能对并发执行的程序加以控制和描述,而引入了进程概念.影响:使程序的并发执行得以实行.6.试从动态性,并发性和独立性上比较进程和程序a.动态性是进程最基本的特性,可表现为由创建而产生,由调度而执行,因得不到资源而暂停执行,以及由撤销而消亡,因而进程由一定的生命期;而程序只是一组有序指令的集合,是静态实体.b.并发性是进程的重要特征,同时也是OS的重要特征.引入进程的目的正是为了使其程序能和其它进程的程序并发执行,而程序是不能并发执行的.c.独立性是指进程实体是一个能独立运行的基本单位,同时也是系统中独立获得资源和独立调度的基本单位.而对于未建立任何进程的程序,都不能作为一个独立的单位参加运行.7.试说明PCB的作用为什么说PCB是进程存在的唯一标志a.PCB是进程实体的一部分,是操作系统中最重要的记录型数据结构.PCB中记录了操作系统所需的用于描述进程情况及控制进程运行所需的全部信息.因而它的作用是使一个在多道程序环境下不能独立运行的程序(含数据),成为一个能独立运行的基本单位,一个能和其它进程并发执行的进程.b.在进程的整个生命周期中,系统总是通过其PCB对进程进行控制,系统是根据进程的PCB而不是任何别的什么而感知到该进程的存在的,所以说,PCB是进程存在的唯一标志.8.试说明进程在三个基本状态之间转换的典型原因.a.处于就绪状态的进程,当进程调度程序为之分配了处理机后,该进程便由就绪状态变为执行状态.b.当前进程因发生某事件而无法执行,如访问已被占用的临界资源,就会使进程由执行状态转变为阻塞状态.c.当前进程因时间片用完而被暂停执行,该进程便由执行状态转变为就绪状态.9.为什么要引入挂起状态该状态具有哪些性质a.引入挂起状态处于5中需要:终端用户的需要,父进程的需要,操作系统的需要,对换的需要和负荷调节的需要.b.处于挂起状态的进程不能接收处理机调度.10在进行进程切换时,所要保存的处理机状态信息主要有哪些a.进程当前暂存信息;b.下一条指令地址信息;c.进程状态信息;d.过程和系统调用参数及调用地址信息.11试说明引起进程创建的主要事件.a.用户登陆;b.作业调度;c.提供服务;d.应用请求.12试说明引起进程撤消的主要事件.a.正常结束;b.异常结束;c.外界干预;13在创建一个进程时,需完成的主要工作是什么a.操作系统发现请求创建新进程事件后,调用进程创建原语Creat();b.申请空白PCB;c.为新进程分配资源;d.初始化进程控制块;e.将新进程插入就绪队列.14在撤消一个进程时,需完成的主要工作是什么a.OS调用进程终止原语;b.根据被终止进程的标志符,从PCB集合中检索出该进程的PCB,从中读出该进程的状态;c.若被终止进程正处于执行状态,应立即中止该进程的执行,并设置调度标志为真;d.若该进程还有子孙进程,还应将其所有子孙进程予以终止;e.将该进程所拥有的全部资源,或者归还给其父进程,或者归还给系统;f.将被终止进程(它的PCB)从所在队列(或链表)中移出,等待其它程序来搜集信息.15试说明引起进程阻塞或被唤醒的主要事件是什么a.请求系统服务;b.启动某种操作;c.新数据尚未到达;d.无新工作可做.17.为什么进程在进入临界区之前,应先执行"进入区"代码,在退出临界区后又执行"退出区"代码为了实现多个进程对临界资源的互斥访问,必须在临界区前面增加一段用于检查欲访问的临界资源是否正被访问的代码,如果未被访问,该进程便可进入临界区对资源进行访问,并设置正被访问标志,如果正被访问,则本进程不能进入临界区,实现这一功能的代码成为"进入区"代码;在退出临界区后,必须执行"退出区"代码,用于恢复未被访问标志.18.同步机构应遵循哪些基本准则为什么a.空闲让进.b.忙则等待.c.有限等待.d.让权等待.20.你认为整型信号量机制和记录型信号量机制,是否完全遵循了同步机构的四条准则a.在整型信号量机制中,未遵循"让权等待"的准则.b.记录型信号量机制完全遵循了同步机构的"空闲让进,忙则等待,有限等待,让权等待"四条准则.23.在生产者-消费者问题中,如果缺少了ignal(full)或ignal(empty),对执行结果会有何影响生产者-消费者问题可描述如下: varmute某,empty,full:emaphore:=1,n,0;buffer:array[0,...,n-1]ofitem;in,out:integer:=0,0;beginparbeginproducer:beginrepeat.produceaniteminne某tp;..wait(empty);wait(mute某);buffer(in):=ne某tp;in:=(in+1)modn;ignal(mute某);/某某某某某某某某某某某某某某某某/ ignal(full);/某某某某某某某某某某某某某某某某/ untilfale;endconumer:beginrepeatwait(full);wait(mute某);ne某tc:=buffer(out);out:=(out+1)modn;ignal(mute某);/某某某某某某某某某某某某某某某某/ ignal(empty);/某某某某某某某某某某某某某某某某/conumetheiteminne某tc;untilfale;endparendend可见,生产者可以不断地往缓冲池送消息,如果缓冲池满,就会覆盖原有数据,造成数据混乱.而消费者始终因wait(full)操作将消费进程直接送入进程链表进行等待,无法访问缓冲池,造成无限等待.24.在生产者-消费者问题中,如果将两个wait操作即wait(full)和wait(mute某)互换位置;或者是将ignal(mute某)与ignal(full)互换位置结果会如何varmute某,empty,full:emaphore:=1,n,0;buffer:array[0,...,n-1]ofitem;in,out:integer:=0,0;beginparbeginproducer:beginrepeat..produceaniteminne某tp;.wait(empty);wait(mute某);buffer(in):=ne某tp;in:=(in+1)modn;/某某某某某某某某某某某某某某某某某某某/ ignal(full);ignal(mute某);/某某某某某某某某某某某某某某某某某某某/ untilfale;endconumer:beginrepeat/某某某某某某某某某某某某某某某某某某/ wait(mute某);wait(full);/某某某某某某某某某某某某某某某某某某/ne某tc:=buffer(out);out:=(out+1)modn;ignal(mute某);ignal(empty);conumetheiteminne某tc;untilfale;endparendendwait(full)和wait(mute某)互换位置后,因为mute某在这儿是全局变量,执行完wait(mute某),则mute某赋值为0,倘若full也为0,则该生产者进程就会转入进程链表进行等待,而生产者进程会因全局变量mute某为0而进行等待,使full始终为0,这样就形成了死锁.而ignal(mute某)与ignal(full)互换位置后,从逻辑上来说应该是一样的.25.我们为某临界区设置一把锁W,当W=1时,表示关锁;W=0时,表示锁已打开.试写出开锁原语和关锁原语,并利用它们去实现互斥.开锁原语:unlock(W):W=0;关锁原语:lock(W);if(W==1)dono_op;W=1;利用开关锁原语实现互斥:varW:emaphore:=0;beginparbeginproce:repeatlock(W);criticalectionunlock(W);remainderectionuntilfale;endparend26.试修改下面生产者-消费者问题解法中的错误: producer:beginrepeat..produceraniteminne某tp;wait(mute某);wait(full);/某应为wait(empty),而且还应该在wait(mute某)的前面某/buffer(in):=ne某tp;/某缓冲池数组游标应前移:in:=(in+1)modn;某/ignal(mute某);/某ignal(full);某/untilfale;endconumer:beginrepeatwait(mute某);wait(empty);/某应为wait(full),而且还应该在wait(mute某)的前面某/ne某tc:=buffer(out);out:=out+1;/某考虑循环,应改为:out:=(out+1)modn;某/ignal(mute某);/某ignal(empty);某/conumeriteminne某tc;untilfale;end27.试利用记录型信号量写出一个不会出现死锁的哲学家进餐问题的算法.设初始值为1的信号量c[I]表示I号筷子被拿(I=1,2,3,4,...,2n),其中n为自然数.end(I):BeginifImod2==1then{P(c[I]);P(c[I-1mod5]);V(c[I-1mod5]);}ele{P(c[I-1mod5]);P(c[I]);Eat;V(c[I]);V(c[I-1mod5]);}End28.在测量控制系统中的数据采集任务,把所采集的数据送一单缓冲区;计算任务从该单缓冲中取出数据进行计算.试写出利用信号量机制实现两者共享单缓冲的同步算法.intmute某=1;intempty=n;intfull=0;intin=0;intout=0;{cobeginend();obtain();coend}end(){while(1){..collectdatainne某tp; ..wait(empty);wait(mute某);buffer(in)=ne某tp;in=(in+1)modn;ignal(mute某);ignal(full);}}//endobtain(){while(1){wait(full);wait(mute某);ne某tc:=buffer(out);out:=(out+1)modn;ignal(mute某);ignal(empty);culculatethedatainne某tc;}//while}//obtain29画图说明管程由哪几部分组成为什么要引入条件变量管程由三部分组成:局部于管程的共享变量说明;对该数据结构进行操作的一组过程;对局部于管程的数据设置初始值的语句.(图见P59)因为调用wait原语后,使进程等待的原因有多种,为了区别它们,引入了条件变量.30.如何利用管程来解决生产者-消费者问题(见P60)31.什么是AND信号量试利用AND信号量写出生产者-消费者问题的解法.为解决并行所带来的死锁问题,在wait操作中引入AND条件,其基本思想是将进程在整个运行过程中所需要的所有临界资源,一次性地全部分配给进程,用完后一次性释放.解决生产者-消费者问题可描述如下:varmute某,empty,full:emaphore:=1,n,0;buffer:array[0,...,n-1]ofitem;in,out:integer:=0,0;beginparbeginproducer:beginrepeat..produceaniteminne某tp;..wait(empty);wait(1,2,3,...,n);//1,2,...,n为执行生产者进程除empty外其余的条件wait(mute某);buffer(in):=ne某tp;in:=(in+1)modn;ignal(mute某);ignal(full);ignal(1,2,3,...,n);untilfale;endconumer:beginrepeatwait(full);wait(k1,k2,k3,...,kn);//k1,k2,...,kn为执行消费者进程除full 外其余的条件wait(mute某);ne某tc:=buffer(out);out:=(out+1)modn;ignal(mute某);ignal(empty);ignal(k1,k2,k3,...,kn);conumetheiteminne某tc;untilfale;endparendend33.试比较进程间的低级通信工具与高级通信工具.用户用低级通信工具实现进程通信很不方便,因为其效率低,通信对用户不透明,所有的操作都必须由程序员来实现.而高级通信工具则可弥补这些缺陷,用户可直接利用操作系统所提供的一组通信命令,高效地传送大量的数据.第三章1.高级调度与低级调度的主要任务是什么为什么要引入中级调度a.作业调度又称宏观调度或高级调度,其主要任务是按一定的原则对外存上处于后备状态的作业进行选择,给选中的作业分配内存,输入输出设备等必要的资源,并建立相应的进程,以使该作业的进程获得竞争处理机的权利.b.进程调度又称微观调度或低级调度,其主要任务是按照某种策略和方法选取一个处于就绪状态的进程,将处理机分配给它.c.为了提高内存利用7.选择调度方式和调度算法时,应遵循的准则是什么a.面向用户的准则有周转时间短,响应时间快,截止时间的保证,以及优先权准则.b.面向系统的准则有系统吞吐量高,处理机利用率好,各类资源的平衡利用.11.在时间片轮转法中,应如何确定时间片的大小?a.系统对响应时间的要求;b.就绪队列中进程的数目;c.系统的处理能力。
操作系统精髓与设计原理第五版课后题答案WordC HAPTER 2O PERATING S YSTEM O VERVIEWReview Questions2.1 Convenience:An operating system makes a computer more convenient touse. Efficiency: An operating system allows the computer systemresources to be used in an efficient manner. Ability to evolve: An operating system should be constructed in such a way as to permit the effective development, testing, and introduction of new systemfunctions without interfering with service.2.5 The execution context, or process state,is the internal data by whichthe operating system is able to supervise and control the process.This internal information is separated from the process, because the operating system has information not permitted to the process. The context includes all of the information that the operating system needs to manage the process and that the processor needs to execute the process properly. The context includes the contents of the various processor registers, such as the program counter and data registers.It also includes information of use to the operating system, such as the priority of the process and whether the process is waiting for the completion 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.4A system call is used by an application program to invoke a functionprovided by the operating system. Typically, the system call results in transfer to a system program that runs in kernel mode.C HAPTER 3P ROCESS D ESCRIPTION AND C 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 beexecuted and the memory areas that can be accessed. This is to protect the operating system from damage or alteration. In kernel mode, the operating system does not have these restrictions, so that it can perform its tasks.Problems3.1?Creation and deletion of both user and system processes. Theprocesses in the system can execute concurrently for information sharing, 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 is created, or allocated to it while it is running. When the process terminates, the OS needs to reclaim any reusable resources.Suspension and resumption of processes.In process scheduling, the OS needs to change the process's state to waiting or ready state when it is waiting for some resources. When the required resources are available, OS needs to change its state to running state to resume its execution.Provision of me chanism for process synchronization. Cooperating processes 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 processes executing under the OS may be either independent processes orcooperating processes. Cooperating processes must have the means to communicate with each other.Provision of mechanisms for deadlock handling. In amultiprogramming environment, several processes may compete for a 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.P ROCESS D ESCRIPTION AND C ONTROLReview Questions4.2 Less state information is involved.4.5 Address space, file resources, execution privileges are examples.4.61. Thread switching does not require kernel mode privileges becauseall of the thread management data structures are within the user address space of a single process. Therefore, the process does not switch to the kernel mode to do thread management. This saves the overhead of two mode switches (user to kernel; kernel back to user).2. Scheduling can be application specific. One application maybenefit most from a simple round-robin scheduling algorithm, while another might benefit from a priority-based scheduling algorithm. The scheduling algorithm can be tailored to the application without disturbing 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.71.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 of multiprocessing. A kernel assigns one process to only one processor at a time. Therefore, only a single thread within a process can execute at a time.Problems4.2Because, with ULTs, the thread structure of a process is not visibleto the operating system, which only schedules on the basis ofprocesses.C ONCURRENCY:M UTUAL E XCLUSION ANDS YNCHRONIZATIONReview Questions5.1Communication among processes, sharing of and competing for resources,synchronization of the activities of multiple processes, andallocation 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.2ABCDE; 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 set blocked[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 ONCURRENCY:D EADLOCK AND S TARVATION Review Questions6.2 Mutual exclusion.Only one process may use a resource at a time. Holdand wait. A process may hold allocated resources while awaiting assignment of others. No preemption. No resource can be forcibly removed 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 resource needed 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) neither p2 nor p3's "still needs" can be satisfied. Soit is not safe to grant p3's request.6.51. 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 addressof 80M. 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 40M30Mb. The three starting addresses are 230M, 20M, and 160M, for the 40M, 20M, and 10M blocks, respectively. 40M 60M 60M 40M 40M 40M30Mc. The three starting addresses are 80M, 120M, and 160M, for the 40M,20M, and 10M blocks, respectively.M EMORY M ANAGEMENT7.12 a. The number of bytes in the logical address space is (216 pages)(210 bytes/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 specifythe frame 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.1Simple 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.2A phenomenon in virtual memory schemes, in which the processor spendsmost of its time swapping pieces rather than executing instructions.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 **4000*2*42*1**32VPN of pages in memory in LRU order 3 2143243434242241241243122。
操作系统教程第五版答案
《操作系统教程第五版》答案是一本涵盖了操作系统概念、原理、设计和实现的教材。
这本书的出版得到了广大读者和教育界的认可和好评。
以下是对该教程的一些综合评价和观点:
首先,该教程的内容全面而深入,涵盖了操作系统基本概念、进程管理、内存管理、文件系统、设备管理等重要章节。
每个章节都以通俗易懂的语言介绍了相关的理论和实践内容,并附有案例研究和练习题,帮助读者巩固所学知识。
其次,该教程在讲解概念和原理的同时,强调了实际应用和设计。
通过对操作系统实现、内核设计和系统优化等内容的讲解,读者能够深入理解操作系统的实际工作原理和解决实际问题的方法。
另外,该教程特别注重操作系统的案例研究和实践操作。
通过分析实际的操作系统案例,读者可以更好地理解和应用所学的知识。
同时,该教程提供了大量的实践操作指导,包括编写简单的操作系统代码、实现进程调度算法等,有助于读者加深对操作系统的理解并提高实践能力。
此外,该教程的编写风格简洁明了,代码清晰易懂。
作者通过简洁的语言和清晰的代码,使得读者能够更好地理解和掌握操作系统的核心概念和技术。
总体来说,《操作系统教程第五版》是一本综合性、权威性和实践性的教材。
它不仅能够帮助读者全面了解操作系统的基本
原理和概念,还能够培养读者的分析和解决问题的能力。
无论是作为学生学习操作系统的教材,还是作为从业人员的参考书,都是一本不可多得的好书。
1 / 7 操作系统教程第5版课后答案 费祥林、骆斌 编著 第一章 操作系统概论 习题一 一、 思考题 1. 简述现代计算机系统的组成及层次结构。 答:现代计算机系统由硬件和软件两个部分组成。是硬件和软件相互交织形成的集合体,构成一个解决计算问题的工具。硬件层提供基本可计算的资源,包括处理器、寄存器、内存、外存及I/O设备。软件层由包括系统软件、支撑软件和应用软件。其中系统软件是最靠近硬件的。 2、计算机系统的资源可分成哪几类?试举例说明。 答:包括两大类,硬件资源和信息资源。硬件资源分为处理器、I/O设备、存储器等;信息资源分为程序和数据等。 3.什么是操作系统?操作系统在计算机系统中的主要作用是什么? 答:操作系统是一组控制和管理计算机硬件和软件资源,合理地对各类作业进行调度,以及方便用户使用的程序的集合。 操作系统在计算机系统中主要起4个方面的作用。 (1) 服务用户观点——操作系统提供用户接口和公共服务程序 (2) 进程交互观点——操作系统是进程执行的控制者和协调者 (3) 系统实现观点——操作系统作为扩展机或虚拟机 (4) 资源管理观点——操作系统作为资源的管理者和控制者 4.操作系统如何实现计算与操作过程的自动化? 答:大致可以把操作系统分为以下几类: 批处理操作系统、分时操作系统、实时操作系统、网络操作系统和分布式操作系统。其中批处理操作系统能按照用户预先规定好的步骤控制作业的执行,实现计算机操作的自动化。又可分为批处理单道系统和批处理多道系统。单道系统每次只有一个作业装入计算机系统的主存储器运行,多个作业可自动、顺序地被装入运行。批处理多道系统则允许多个作业同时装入主存储器,中央处理器轮流地执行各个作业,各个作业可以同时使用各自所需的外围设备,这样可以充分利用计算机系统的资源,缩短作业时间,提高系统的吞吐率 5.操作系统要为用户提供哪些基本的和共性的服务? 答:(1)创建程序和执行程序;(2)数据I/O和信息存取;(3)通信服务;(4)差错检测和处理。为了保证高效率、高质量的工作,使得多个应用程序能够有效的共享系统资源,提高系统效率,操作系统还具备一些其他的功能:资源分配,统计,保护等。 6.试述操作系统所提供的各种用户接口。 答:操作系统通过程序接口和操作接口将其服务和功能提供给用户。程序接口由一组系统调用组成,在应用程序中使用“系统调用” 可获得操作系统的低层服务, 访问或使用系统管理的各种软硬件资源,是操作系统对外提供服务和功能的手段;操作接口由一组命令和(或)作业控制语言组成,是操作系统为用户提2 / 7
供的组织和控制作业执行的手段。 7.什么是系统调用?可分为哪些类型? 答:操作系统为了达到为应用程序的运行提供良好的环境, 系统内核提供了一系列具备预定功能的内核函数, 这一组特殊接口被称为系统调用。操作系统所提供的系统调用按功能可分为六类: 1) 进程管理;2)文件操作;3)设备管理;4)主存管理;5) 进程通信;6) 信息维护。 8.什么是实用程序,可分为哪些类型? 答:实用程序又称支撑程序,是为应用程序的开发、调试、执行和维护解决共性问题或执行公共操作提供的一组程序。按功能可分为:1)文件管理;2)语言支持;3) 状态修改;4)支持程序执行;5)通信等。 9.试述系统调用的实现原理。 操作系统实现系统调用功能的机制称为陷阱或异常处理机制。其实现原理是: 首先编写系统调用函数并且设计系统调用入口地址表,每个入口地址都指向一个系统调用的内核函数,有些还包含系统调用自带参数的个数。然后开辟现场保护区, 用以保存发生系统调用时的处理器现场。 10.试述系统调用与函数过程调用之间的主要区别。 答:在程序执行系统调用或过程调用中两者的主要区别是: 1)调用的形式和实现的方式不同;2)被调用的代码的位置不同;3)提供方式不同。 11.试述API(Application program interface)、库函数与系统调用之间的关系. 答:API是由同名的封装把系统调用封装成应用程序能够直接使用的应用接口。所以,一个库函数就是一种API,一个API 的实现可能会用到一个系统调用或多个系统调用,也可能若干API 封装相同的系统调用,即使完全不使用系统调用,也不存在任何问题。 12.试解释脱机I/O和假脱机I/O。 答:1)脱机输入输出方式( Off-Line I/O )是为了解决人机矛盾CPU和I/O 设备之间速度不匹配而提出的。它减少了CPU的空闲等待时间, 提高了I/O 速度。具体内容是将用户程序和数据在一台外围机的控制下, 预先从低速输入设备到磁带上, 当CPU需要这些程序和数据时,在直接从磁带机高速输入到内存, 从而大大加快了程序的输入过程, 减少了CPU等待输入的时间,这就是脱机输入技术;当程序运行完毕或告一段落, CPU需要时,无需直接把计算结果送至低速输出设备, 而是高速把结果输出到磁带上, 然后在外围机的控制下, 把磁带上的计算结果由相应的输出设备输出,这就是脱机输出技术。2)若这种输入输出操作在主机控制下进行,则称之为联机输入输出方式。 13.为什么对作业进行批处理可以提高系统效率? 答:多道程序系统可以利用CPU的等待时间来运行其它程序。 14.举例说明计算机体系结构的不断改进是操作系统发展的主要动力之一。 答:计算机体系的基本结构遵循冯诺依曼体系结构,主要由运算器、控制器、存储器、输入设备、输出设备五部分组成。随着CPU不断升级,存储器的容量不断增大,计算机体系结构不断的改进,从而,要求计算机的操作系统不断的更新,由原来的DOS到后来的Windows98,Windows 2000,Windows XP,UNIX,LINIX 和Windows 2003 等。 15.什么是多道程序设计?多道程序设计技术有什么特点? 答。多道程序设计是指允许多个作业同时进入计算机系统的主存并启动交替计算的方法。其特点是: 1)CPU、主存和设备的利用率高。2)系统的吞吐率提高,3 / 7
单位时间内完成的作业数增加。3)充分发挥了系统的并行性,设备与设备之间、CPU与设备之间均可并行工作。 16.简述实现多道程序设计所必须解决的基本问题。 答:实现多道程序设计所必须解决的三个问题: 1)存储保护和地址重定位; 2)处理机管理和调度; 3)资源的管理和分配。 17.计算机系统采用通道部件后,已实现处理器与外部设备的并行工作,为什么还要引入多道程序设计技术? 答:引入多道程序设计技术的根本目的是提高CPU的利用率, 充分发挥计算机系统部件的并行性,一些应用问题也只有靠多道程序设计技术才能有效解决。 18.什么是实时操作系统?试述实时操作系统的分类。 答:实时操作系统( Real Time Operating System)指当外界事件或数据产生时,能接收并足够快的速度予以处理, 处理的结果又能在规定时间内来控制监控的生产过程或对任务协调 一致运行的操作系统。分类: 1)过程控制系统:如生产过程控制系统、导弹制导系统、飞机自动驾驶系统、火炮自动控制系统。 2)信息查询系统:计算机同时从成百上千的终端接受服务请求和提问,并在短时间内作出回答和响应。如情报检索系统。 3)事务处理系统:计算机不仅要对终端用户及时作出响应,还要频繁更新系统中的文件或数据库。如银行业务系统。 19.在分时系统中,什么是响应时间?它与哪些因素有关? 答:分时系统的响应时间是指用户从终端发出一个命令到系统处理完这个命令并做出回答所需要的时间。这个时间受时间片长度、终端用户个数、命令本身功能、硬件特性、主存与辅存的交换速度等影响。 20.试比较批处理操作系统与分时操作系统的不同点。 答:分时操作系统与批处理操作系统的区别: 1)追求目标不同:批处理操作系统以提高系统资源利用率和作业吞吐能力为目标, 分时操作系统强调公平性对于联机用户的立即执行命令需要快速响应。2)适应作业不同:批处理操作系统适应已调试好的大型作业,分时操作系统适应正在调试的小型作业。3)资源利用率不同:批处理操作系统可合理安排不同负载的作业,使资源利用率达到最佳;在分时操作系统中,多个终端的作业使用同类型的系统运行系统和共同子程序使系统的高度开销小,能公平的调配CPU和存储资源。4)作业控制方式不同:批处理操作系统由用户通过( JCL)书写作业控制流,预先提交脱机作业;分时 操作系统交互作业由用户从键盘输入控制命令以交互方式联机工作。 21.试比较实时操作系统与分时操作系统的不同点。 答:分时操作系统是指在一个系统中多个用户分时地使用同一台计算机;实时操作系统是指计算机及时响应外部事件地请求并在规定时限内完成对该事件的处理, 控制所有实时高备和实时任务协调一致地运行。 实时操作系统和分时操作系统的主要区别有两点: 1)分时操作系统的目标是提供一种通用性很强的系统, 有较强的交互能力。 而实时操作系统则大都是具有特殊用途的专用系统,交互能力略差。 2)分时操作系统对响应时间虽有要求,但一般来说,响应时间由人所能承受的等待时间来确定;而实时操作系统对响应时间要求很高, 一般由控制系统或信息处理磁头所能接受的延迟时间来决定。 4 / 7
22.试比较单道和多道批处理系统。 答:1)单道批处理系统是最早出现的一种OS,它具有自动性,顺序性和单道性的特点;多道批处理系统则具有调度性,无序性和多道性的特点。2)单道批处理系统是在解决要人机矛盾及CPU和I/O 设备之间速度不匹配的矛盾中形成的, 旨在提高系统资源利用率和系统吞吐量,但是仍然不能很好的利用系统资源; 多道批处理系统是对单道批处理系统的改进, 其主要优点是资源利用率高,系统吞吐量大;缺点是平均周转时间长,无交互能力。 23.现代操作系统具有哪些基本的功能,请简单叙述之。 答:现代操作系统的功能:管理计算机的软硬件资源(包括:处理机管理,作业管理,存储管理,设备管理,文件管理)、提高资源的利用率、方便用户。 24.试述现代操作系统的基本特性及所要解决的主要问题。 答:操作系统的四个基本特征: 1)并发性( concurrence ), 2)共享性( sharing ), 3)虚拟性( virtual ), 4)异步性( asynchronism )。 所要解决的主要问题是: 提高计算机系统的效率; 增强系统的处理能力; 方便用户使用。 25.为什么操作系统会有随机性特性? 答:在多道程序环境中允许多个程序并发执行,并发活动会导致随机事件的发生。操作系统中的随机事件处处可见,不可预见。所以操作系统必须能够及时捕捉并正确处理。 26.组成操作系统的构件有哪些?请简单叙述之。 答:操作系统的结构设计有:单体式、层次式、虚拟机和微内核结构。Linux采用单体式的结构设计,主要构件有内核、shell、应用程序。 27.什么是操作系统内核? 答:内核是一组程序模块,作为可信软件来支持进程并发执行的基本功能和基本操作。通常驻留在内核空间,运行于内核态,具有直接访问硬件设备和所有内存空间的权限,是仅有的能够执行特权指令的程序。 28.列举内核的分类、属性及特点。 答:内核按大小分为仅有极少必须功能的微内核,和大部分功能都并入内核的单内核。内核的属性:1)内核是由中断程序引出的;2)内核可以在屏蔽中段状态下执行;3)内核是不可抢占的;4)内核可使用特权命令。内核的功能:1)中断处理;2)时钟管理;3)短程调度;4)原语管理。 29.简述单内核操作系统及其优缺点。 答:单内核操作系统是将系统的大部分功能都并入到内核中。采用模块组合法,是基于结构化设计的一种软件结构设计方法。优点:结构紧密、组合方便、对不同的环境和用户的不同需求可以组合不同的模块来满足,灵活性强。缺点:模块的独立性差,系统的功能增、删、改困难,可靠性低。 30.简述微内核及客户——服务器结构操作系统及其优缺点。 答:将操作系统分为两个部分,一是运行在内核态的内核,提供系统基本功能。二是运行于用户态以客户——服务器方式执行的进程层。优点:1)对进程请求提供一致性的接口;2)具有较好的可扩充性和易修改性;3)可移植性好;4)对分布式系统提供良好的支撑。缺点:运行效率较低。 31.什么是层次式操作系统?试说明其优缺点。 答:层次式结构把操作系统划分为内核和若干模块,这些模块按功能的调用次序排列成若干层次,各层之间只能存在单向依赖或单向调用关系。优点:1)把整