操作系统第五版费祥林_课后习题答案解析参考
操作系统教程第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之间(见图中有色部分)。
操作系统第五版习题中文解答-精共18页PPT
操作系统第五版习题中文解答-精
16、人民应该为法律而战斗,就像为 了城墙 而战斗 一样。 ——赫 拉克利 特 17、人类对于不公正的行为加以指责 ,并非 因为他 们愿意 做出这 种行为 ,而是 惟恐自 己会成 为这种 行为的 牺牲者 。—— 柏拉图 18、制定法律法令,就是为了不让强 者做什 么事都 横行霸 道。— —奥维 德 19、法律是社会的习惯和思想的结晶 。—— 托·伍·威尔逊 20、人们嘴上挂着的法律,其真实含 义是财 富。— —爱献 生
41、学问是异常珍贵的东西,从任何源泉吸 收都不可耻。——阿卜·日·法拉兹
42、只有在人群中间,才能认识自 己。——德国
43、重复别人所说的话,只需要教育; 而要挑战别人所说的话,则需要头脑。—— 玛丽· Nhomakorabea蒂博恩·普尔
44、卓越的人一大优点是:在不利与艰 难的遭遇里百折不饶。——贝多芬
操作系统第五版费祥林-课后习题答案参考
操作系统第五版费祥林-课后习题答案参考第二章处理器管理1.下列指令中哪些只能在核心态运行?(l)读时钟日期;(2)访管指令;(3)设时钟日期;(4)加载PSW; (5)置特殊寄存器:(6)改变存储器映象图;(7)启动I/O指令。
答:( 3 ) , ( 4 ) , ( 5 ) , ( 6 ) , ( 7 ) .2 假设有一种低级调度算法是让“最近使用处理器较少的进程”运行,试解释这种算法对“I/O 繁重”型作业有利,但并不是永远不受理“处理器繁重”型作业。
答:因为I/O繁忙型作业忙于I/O,所以它CPU 用得少,按调度策略能优先执行。
同样原因一个进程等待CPU 足够久时,由于它是“最近使用处理器较少的进程”,就能被优先调度,故不会饥饿。
3 并发进程之间有什么样的相互制约关系?下列日常生活中的活动是属哪种制约关系:(1)踢足球,(2)吃自助餐,(3)图书馆借书,(4)电视机生产流水线工序。
答:并发进程之间的基本相互制约关系有互斥和同步两种。
其中(1)、(3)为互斥问题.(2)、(4)为同步问题。
4 在按动态优先数调度进程的系统中,每个进程的优先数需定时重新计算。
在处理器不断地在进程之间交替的情况下,重新计算进程优先数的时间从何而来?答:许多操作系统重新计算进程的优先数在时钟中断处理例程中进行,由于中断是随机碰到哪个进程,就插入哪个进程中运行处理程序,并把处理时间记在这个进程的账上。
5 若后备作业队列中等待运行的同时有三个作业J1 、J2、J3 ,已知它们各自的运行时间为a 、b 、c,且满足a < b <c,试证明采用短作业优先算法调度能获得最小平均作业周转时间。
答:采用短作业优先算法调度时,三个作业的总周转时间为:Tl = = a + ( a +b ) + ( a + b + c ) = 3a + 2b + c ①若不按短作业优先算法调度,不失一般性,设调度次序为:J2 、J1 、J3 。
则三个作业的总周转时间为:T2=b+(b+a ) +(b+a + c ) = 3b + 2a + c ②令②-①式得到:T2 - Tl = b- a> 0可见,采用短作业优先算法调度才能获得最小平均作业周转时间。
操作系统教程第五版答案
操作系统教程第五版答案【篇一:华科操作系统教程(第五版)费祥林部分习题答案】>应用题t2、t4、第二章处理器管理应用题t1:只能在内核态运行的指令:(3)、(4)、(5)、(6)、(7)。
t11:(4)sjf调度算法t15:hrrf性能较好。
第三章同步、通信与死锁应用题:2、5(1)、38(1),t2、t5、t38(1)第四章存储管理二、应用题:3(3)、5、20、30t3(3)答:作业的物理块数为3时,fifo为9次,75%;lru为10次,83%;opt为7次,58%;作业的物理块数为4时,fifo为10次,83%,lru为8次,66%,opt为6次,50%。
其中fifo出现belady现象。
t5、【篇二:操作系统原理习题及答案(全书免费版)】、填空题1.用户与操作系统的接口有,两种。
【答案】命令接口,系统调用【解析】按用户界面的观点,操作系统是用户与计算机之间的接口。
用户通过操作系统提供的服务来有效地使用计算机。
一般操作系统提供了两类接口为用户服务,一种是程序一级的接口,即通过一组广义指令(或称系统调用)供用户程序和其他系统程序调用;另一种是作业一级的接口,提供一组控制命令供用户去组织和控制自己的作业。
2.用户程序调用操作系统有关功能的途径是。
【答案】利用系统调用命令【解析】系统调用命令是操作系统专门给编程人员提供的调用操作系统有关功能的途径,一般在汇编语言和c语言中都提供了使用系统调用命令的方法。
编程人员可以在这些语言中利用系统调用命令动态请求和释放系统资源。
3.unix系统是①操作系统,dos系统是②操作系统。
【答案】①分时(或多用户、多任务),②单用户(或单用户、单任务)【解析】 unix系统是一个可供多个用户同时操作的会话式的分时操作系统,dos系统是为个人计算机设计的一个单用户操作系统。
4.现代计算机中,cpu工作方式有目态和管态两种。
目态是指运行①程序,管态是指运行②程序。
操作系统精髓与设计原理第五版 课后题答案
操作系统精髓与设计原理第五版课后题答案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。
操作系统教程第5版部分习题答案
操作系统教程第 5 版部分习题答案第一章:一、3、10、15、23、27、353. 什么是操作系统?操作系统在计算机系统中的主要作用是什么?操作系统是管理系统资源、控制程序执行、改善人机界面、提供各种服务,并合理组织计算机工作流程和为用户有效地使用计算机提供良好运行环境的一种系统软件.主要作用(1)服务用户—操作系统作为用户接口和公共服务程序(2)进程交互—操作系统作为进程执行的控制者和协调者(3)系统实现—操作系统作为扩展机或虚拟机(4)资源管理—操作系统作为资源的管理者和控制者10. 试述系统调用与函数(过程)调用之间的区别。
1)调用形式和实现方式不同;操作系统教程第 5 版部分习题答案(2)被调用的代码位置不同;(3)提供方式不同15. 什么是多道程序设计?多道程序设计有什么特点?多道程序设计是指允许多个作业 (程序)同时进入计算机系统内存并执行交替计算的方法。
从宏观上看是并行的,从微观上看是串行的。
(1)可以提高CPU内存和设备的利用率;( 2) 可以提高系统的吞吐率,使单位时间内完成的作业数目增加;( 3) 可以充分发挥系统的并行性,使设备和设备之间,设备和CPU 之间均可并行工作。
23. 现代操作系统具有哪些基本功能?请简单叙述之。
( 1 )处理器管理;( 2)存储管理;( 3)设备管理;操作系统教程第 5 版部分习题答案(4)文件管理;(5)联网与通信管理。
27. 什么是操作系统的内核?内核是一组程序模块,作为可信软件来提供支持进程并发执行的基本功能和基本操作,通常驻留在内核空间,运行于内核态,具有直接访问计算机系统硬件设备和所有内存空间的权限,是仅有的能够执行特权指令的程序。
35. 简述操作系统资源管理的资源复用技术。
系统中相应地有多个进程竞争使用资源,由于计算机系统的物理资源是xx 和稀有的,操作系统让众多进程共享物理资源,这种共享称为资源复用。
(1)时分复用共享资源从时间上分割成更小的单位供进程使用;(2)空分复用共享资源从空间上分割成更小的单位供进程使用。
操作系统教程第五版课后答案
操作系统教程第五版课后答案操作系统教程第五版是操作系统学习的权威参考书之一,对于深入了解和掌握操作系统的原理、概念、设计和实现具有重要意义。
课后答案是对教材中习题的解析和讲解,对学生来说是巩固知识、检验理解的重要工具。
以下是对该教材第五版的课后答案的总结分析。
该教材第五版的课后答案一般由三个部分组成:填空题、选择题和编程题。
填空题主要考察对概念和定义的理解,要求学生通过查阅教材或其他参考资料来获取相关知识。
选择题旨在考察学生对知识点的理解程度和对重点和难点的把握程度,答案往往需要较为详细的解释和分析,以便帮助学生更好地理解。
编程题主要考察学生对操作系统相关概念和原理的应用能力,要求学生设计和实现简单的操作系统功能。
在课后答案的编写过程中,需要注意一下几个方面:首先,答案应该清晰明了,用简洁的语言阐述。
其次,需要提供详细的解释和推理过程,以便学生理解。
第三,应该尽量避免使用晦涩难懂的术语和符号,以免给学生造成困扰。
最后,答案应该准确无误,没有错误和疏漏。
在学生阅读课后答案时,应该注意以下几点:首先,应该认真阅读教材并理解其中的内容,充分利用教材中的例题和习题进行巩固和扩展。
其次,应该对比教材中的答案和自己的解答,对照着学习,找出差距并加以改进。
第三,要积极参考教材中提到的相关参考资料,扩大知识面。
最后,利用答案的解析部分,对相关知识点和难点进行深入理解,为今后的学习打下坚实基础。
总之,操作系统教程第五版的课后答案对学生来说是一个重要的学习工具,对于巩固知识、检验理解有着积极的作用。
学生在阅读和使用答案时应该充分利用教材和参考资料,提高自己的问题解决能力和编程能力,为深入理解和应用操作系统知识打下坚实基础。
操作系统第五版1-12章课后题中文答案
复习题: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模块发布命令(用以执行这个指令);在进一步的动作之前,处理器处于繁忙的等待中,直到该操作已经完成。
操作系统第五版答案-费翔林
第一章操作系统概论1、有一台计算机,具有IMB 内存,操作系统占用200KB ,每个用户进程各占200KB 。
如果用户进程等待I/O 的时间为80 % ,若增加1MB 内存,则CPU 的利用率提高多少?答:设每个进程等待I/O 的百分比为P ,则n 个进程同时等待刀O 的概率是Pn ,当n 个进程同时等待I/O 期间CPU 是空闲的,故CPU 的利用率为1-Pn。
由题意可知,除去操作系统,内存还能容纳4 个用户进程,由于每个用户进程等待I/O 的时间为80 % , 故:CPU利用率=l-(80%)4 = 0.59若再增加1MB 内存,系统中可同时运行9 个用户进程,此时:cPu 利用率=l-(1-80%)9 = 0.87故增加IMB 内存使CPU 的利用率提高了47 % :87 %/59 %=147 %147 %-100 % = 47 %2 一个计算机系统,有一台输入机和一台打印机,现有两道程序投入运行,且程序A 先开始做,程序B 后开始运行。
程序A 的运行轨迹为:计算50ms 、打印100ms 、再计算50ms 、打印100ms ,结束。
程序B 的运行轨迹为:计算50ms 、输入80ms 、再计算100ms ,结束。
试说明(1 )两道程序运行时,CPU有无空闲等待?若有,在哪段时间内等待?为什么会等待?( 2 )程序A 、B 有无等待CPU 的情况?若有,指出发生等待的时刻。
答:画出两道程序并发执行图如下:(1)两道程序运行期间,CPU存在空闲等待,时间为100 至150ms 之间(见图中有色部分)(2)程序A 无等待现象,但程序B 有等待。
程序B 有等待时间段为180rns 至200ms 间(见图中有色部分)3 设有三道程序,按A 、B 、C优先次序运行,其内部计算和UO操作时间由图给出。
试画出按多道运行的时间关系图(忽略调度执行时间)。
完成三道程序共花多少时间?比单道运行节省了多少时间?若处理器调度程序每次进行程序转换化时lms , 试画出各程序状态转换的时间关系图。
操作系统第五版1-12章课后题中文答案
复习题: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模块发布命令(用以执行这个指令);在进一步的动作之前,处理器处于繁忙的等待中,直到该操作已经完成。
(完整版)操作系统教程第5版课后答案解析
操作系统教程第5版课后答案费祥林、骆斌编著第一章操作系统概论习题一一、思考题1.简述现代计算机系统的组成及层次结构。
答:现代计算机系统由硬件和软件两个部分组成。
是硬件和软件相互交织形成的集合体,构成一个解决计算问题的工具。
硬件层提供基本可计算的资源,包括处理器、寄存器、内存、外存及I/O设备。
软件层由包括系统软件、支撑软件和应用软件。
其中系统软件是最靠近硬件的。
2、计算机系统的资源可分成哪几类?试举例说明。
答:包括两大类,硬件资源和信息资源。
硬件资源分为处理器、I/O设备、存储器等;信息资源分为程序和数据等。
3•什么是操作系统?操作系统在计算机系统中的主要作用是什么?答:操作系统是一组控制和管理计算机硬件和软件资源,合理地对各类作业进行调度,以及方便用户使用的程序的集合。
操作系统在计算机系统中主要起4个方面的作用。
(1)服务用户观点一—操作系统提供用户接口和公共服务程序(2)进程交互观点一—操作系统是进程执行的控制者和协调者(3)系统实现观点一—操作系统作为扩展机或虚拟机(4)资源管理观点一—操作系统作为资源的管理者和控制者4.操作系统如何实现计算与操作过程的自动化?答:大致可以把操作系统分为以下几类:批处理操作系统、分时操作系统、实时操作系统、网络操作系统和分布式操作系统。
其中批处理操作系统能按照用户预先规定好的步骤控制作业的执行,实现计算机操作的自动化。
又可分为批处理单道系统和批处理多道系统。
单道系统每次只有一个作业装入计算机系统的主存储器运行,多个作业可自动、顺序地被装入运行。
批处理多道系统则允许多个作业同时装入主存储器,中央处理器轮流地执行各个作业,各个作业可以同时使用各自所需的外围设备,这样可以充分利用计算机系统的资源,缩短作业时间,提高系统的吞吐率5 •操作系统要为用户提供哪些基本的和共性的服务?答:(1)创建程序和执行程序;(2)数据I/O和信息存取;(3)通信服务;(4)差错检测和处理。
操作系统第五版费祥林-课后习题答案解析参考
第一章操作系统概论1、有一台计算机,具有IMB 内存,操作系统占用200KB ,每个用户进程各占200KB 。
如果用户进程等待I/O 的时间为80 % ,若增加1MB 内存,则CPU 的利用率提高多少?答:设每个进程等待I/O 的百分比为P ,则n 个进程同时等待刀O 的概率是Pn ,当n 个进程同时等待I/O 期间CPU 是空闲的,故CPU 的利用率为1-Pn。
由题意可知,除去操作系统,内存还能容纳4 个用户进程,由于每个用户进程等待I/O的时间为80 % , 故:CPU利用率=l-(80%)4 = 0.59若再增加1MB 内存,系统中可同时运行9 个用户进程,此时:cPu 利用率=l-(1-80%)9 = 0.87故增加IMB 内存使CPU 的利用率提高了47 % :87 %/59 %=147 %147 %-100 % = 47 %2 一个计算机系统,有一台输入机和一台打印机,现有两道程序投入运行,且程序A 先开始做,程序B 后开始运行。
程序A 的运行轨迹为:计算50ms 、打印100ms 、再计算50ms 、打印100ms ,结束。
程序B 的运行轨迹为:计算50ms 、输入80ms 、再计算100ms ,结束。
试说明(1 )两道程序运行时,CPU有无空闲等待?若有,在哪段时间内等待?为什么会等待?( 2 )程序A 、B 有无等待CPU 的情况?若有,指出发生等待的时刻。
答:画出两道程序并发执行图如下:(1)两道程序运行期间,CPU存在空闲等待,时间为100 至150ms 之间(见图中有色部分)(2)程序A 无等待现象,但程序B 有等待。
程序B 有等待时间段为180rns 至200ms 间(见图中有色部分)3 设有三道程序,按A 、B 、C优先次序运行,其内部计算和UO操作时间由图给出。
试画出按多道运行的时间关系图(忽略调度执行时间)。
完成三道程序共花多少时间?比单道运行节省了多少时间?若处理器调度程序每次进行程序转换化时lms , 试画出各程序状态转换的时间关系图。
操作系统第五版费祥林_课后习题答案解析参考
第一章操作系统概论1、有一台计算机,具有IMB 内存,操作系统占用200KB ,每个用户进程各占200KB 。
如果用户进程等待I/O得时间为80 % ,若增加1MB 内存,则CPU 得利用率提高多少?ﻫ答:设每个进程等待I/O 得百分比为P ,则n 个进程同时等待刀O 得概率就是Pn ,当n个进程同时等待I/O 期间CPU 就是空闲得,故CPU 得利用率为1-Pn。
由题意可知,除去操作系统,内存还能容纳4个用户进程,由于每个用户进程等待I/O得时间为80 % , 故:CPU利用率=l-(80%)4 = 0、59若再增加1MB内存,系统中可同时运行9 个用户进程,此时:cPu 利用率=l-(1—80%)9 = 0、87 ﻫ故增加IMB 内存使CPU得利用率提高了47 %:87 %/59 %=147 %147 %-100 % = 47 %2 一个计算机系统,有一台输入机与一台打印机,现有两道程序投入运行,且程序A 先开始做,程序B 后开始运行.程序A 得运行轨迹为:计算50ms 、打印100ms 、再计算50ms 、打印100ms ,结束。
程序B 得运行轨迹为:计算50ms、输入80ms 、再计算100ms ,结束。
试说明(1 )两道程序运行时,CPU有无空闲等待?若有,在哪段时间内等待?为什么会等待?( 2 )程序A、B 有无等待CPU得情况?若有,指出发生等待得时刻。
答:(1)两道下:ﻫﻫ程序运行期间,CPU存在空闲等待,时间为100 至150ms之间(见图中有色部分)ﻫ(2)程序A 无等待现象,但程序B 有等待。
程序B 有等待时间段为180rns至200ms 间(见图中有色部分)ﻫ3设有三道程序,按A 、B 、C优先次序运行,其内部计算与UO操作时间由图给出.ﻫ试画出按多道运行得时间关系图(忽略调度执行时间)。
完成三道程序共花多少时间?比单道运行节省了多少时间?若处理器调度程序每次进行程序转换化时lms , 试画出各程序状态转换得时间关系图。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
第一章操作系统概论1、有一台计算机,具有 IMB 内存,操作系统占用 200KB ,每个用户进程各占200KB 。
如果用户进程等待 I/O 的时间为 80 % ,若增加 1MB 内存,则 CPU的利用率提高多少?答:设每个进程等待 I/O 的百分比为 P ,则 n 个进程同时等待刀 O 的概率是 Pn ,当 n 个进程同时等待 I/O 期间 CPU是空闲的,故 CPU 的利用率为 1-Pn。
由题意可知,除去操作系统,内存还能容纳 4 个用户进程,由于每个用户进程等待 I/O 的时间为 80 % , 故:CPU利用率= l- (80%)4 = 0.59若再增加 1MB 内存,系统中可同时运行9 个用户进程,此时: cPu 利用率= l-(1-80%)9 = 0.87故增加 IMB 内存使 CPU 的利用率提高了47 % :87% /59 % =147 %147%-100 % = 47 %2一个计算机系统,有一台输入机和一台打印机,现有两道程序投入运行,且程序A 先开始做,程序 B 后开始运行。
程序 A 的运行轨迹为:计算 50ms 、打印 100ms 、再计算50ms 、打印100ms ,结束。
程序 B 的运行轨迹为:计算50ms 、输入80ms 、再计算 100ms ,结束。
试说明( 1 )两道程序运行时, CPU有无空闲等待?若有,在哪段时间内等待?为什么会等待?(2)程序A、B有无等待CPU 的情况?若有,指出发生等待的时刻。
答:画出两道程序并发执行图如下:(1)两道程序运行期间, CPU存在空闲等待,时间为 100 至 150ms 之间(见图中有色部分)(2)程序 A 无等待现象,但程序 B 有等待。
程序 B 有等待时间段为 180rns 至200ms 间(见图中有色部分)3 设有三道程序,按 A 、B 、 C 优先次序运行,其内部计算和 UO操作时间由图给出。
试画出按多道运行的时间关系图(忽略调度执行时间)。
完成三道程序共花多少时间?比单道运行节省了多少时间?若处理器调度程序每次进行程序转换化时lms , 试画出各程序状态转换的时间关系图。
答:1 )忽略调度执行时间 , 多道运行方式(抢占式):抢占式共用去 190ms ,单道完成需要260ms ,节省 70ms 。
忽略调度执行时间,多道运行方式(非抢占式):非抢占式共用去180ms ,单道完成需要260ms ,节省 80ms 。
2 )调度执行时间 1ms ,多道运行方式(抢占式):调度执行时间 ITns,多道运行方式(非抢占式):4 在单 CPU 和两台 I/O( I1 , 12 )设备的多道程序设计环境下,同时投入三个作业运行。
它们的执行轨迹如下:Jobl : I2 ( 30ms )、 CPU( 10ms )、 I1 ( 30ms )、CPU( 10ms )、I2 ( 20ms)Job2 : I1 ( 20ms)、CPU ( 20ms)、I2 ( 40 ms )JOb3 : CPU ( 30ms)、I1 ( 20ms)、CPU ( 10ms)、I1 ( 10ms )如果 CPU 、I1和I2都能并行工作,优先级从高到低为Jobl、Job2优先级高的作业可以抢占优先级低的作业的CPU,但不抢占 I1 和 I2和 Job3 ,。
试求:( l )每个作业从投入到完成分别所需的时间。
(2 )从投入到完成CPU 的利用率。
( 3 )I2 设备利用率。
答:画出三个作业并行工作图如下(图中着色部分为作业等待时间): ,( 1 ) Job1 从投入到运行完成需 110ms , Job2 从投入到运行完成需 90ms, Job3 从投入到运行完成需 110ms.CPU 空闲时间段为: 60ms 至 70ms, 80ms 至 90ms, 100ms 至 110ms 。
所以 CPU利用率为( 110-30 )/10 = 72.7设备 I1空闲时间段为:20ms至%。
40ms , 90ms至 100ms,故I1的利用率为(110-30)/l10 = 72 . 7%。
设备I2空闲时间段为: 30ms 至50ms,故I2的利用率为(110-20) / 110 =81.8%。
5 在单CPU和两台I/O(I1,12)设备的多道程序设计环境下,同时投入三个作业运行。
它们的执行轨迹如下:Jobl : I2 ( 30ms)、CPU ( 10rns)、I1 ( 30ms)、CPU ( 10ms )Job2 : I1 ( 20ms)、CPU ( 20ms)、I2 ( 40ms )Job3 : CPU ( 30ms)、I1 ( 20ms )如果 CPU 、I1 和 I2都能并行工作,优先级从高到低为Job1 、Job2 和Job3,优先级高的作业可以抢占优先级低的作业的 CPU。
试求: ( l )每个作业从投入到完成分别所需的时间. ( 2 )每个作业投入到完成 CPU 的利用率。
(3 )I/0 设备利用率。
答:画出三个作业并行工作图如下(图中着色部分为作业等待时间):( 1 ) Job1 从投入到运行完成需 80ms , Job2 从投入到运行完成需 90ms , Job3 从投入到运行完成需 90ms 。
( 2 ) CPU空闲时间段为:60ms至70ms , 80ms至90ms。
所以CPU利用率为( 90-20 ) / 90 = 77.78%。
( 3 )设备 I1空闲时间段为:20ms至40ms,故I1的利用率为(90-20 ) / 90= 77 . 78 %。
设备 I2空闲时间段为:30ms至50ms,故I2的利用率为(90-20 ) / 90=77.78%。
6若内存中有 3 道程序 A 、B 、C ,它们按 A 、B 、C 优先次序运行。
各程序的计算轨迹为:A :计算( 20)、 I/O( 30)、计算( 10 )B :计算( 40)、 I/O( 20)、计算( 10 )c :计算( 10)、 I/O ( 30)、计算( 20 )如果三道程序都使用相同设备进行 I/O (即程序用串行方式使用设备,调度开销忽略不计)。
试分别画出单道和多道运行的时间关系图。
两种情况下, CPU 的平均利用率各为多少?答:分别画出单道和多道运行的时间图( 1)单道运行时间关系图单道总运行时间为 190ms 。
CPU 利用率为( 190-80 )/190 = 57.9 %单道运行时间关系图多道总运行时间为140ms 。
CPU 利用率为( 140-30 ) / 140 = 78.6 %7 若内存中有 3 道程序 A 、B 、C ,优先级从高到低为 A 、B 和 C ,它们单独运行时的 CPU和 I/O 占用时间为:如果三道程序同时并发执行,调度开销忽略不计,但优先级高的程序可中断优先级低的程序,优先级与 I/O 设备无关。
试画出多道运行的时间关系图,并问最早与最迟结束的程序是哪个?每道程序执行到结束分别用了多少时间?计算三个程序全部运算结束时的 CPU 利用率?答:画出三个作业并发执行的时间图:( l ( 2)最早结束的程序为 B ,最后结束的程序为C)程序 A 为 250ms 。
程序 B 为 220ms 。
程序。
C 为310ms 。
( 3 ) CPU利用率为(310 -120 ) / 310 = 61.3 %有两个程序, A 程序按顺序使用: ( CPU)10 秒、(设备甲) 5 秒、(CPU)5 秒、(设备乙) 10 秒、(CPU)10 秒。
B 程序按顺序使用:(设备甲) 10 秒、(CPU)10 秒、(设备乙) 5 秒、( CPU)5 秒、(设备乙) 10 秒。
在顺序环境下先执行A ,再执行B ,求出总的 CPU 利用率为多少?答:程序 A 执行了 40 秒,其中 CPU 用了 25 秒。
程序 B 执行了 40 秒,其中 CPU用了 15 秒。
两个程序共用了 80 秒,CPU化 40 秒。
故 CPU 利用率为 40/80=50 %。
9、在某计算机系统中,时钟中断处理程序每次执行的时间为 2ms (包括进程切换开销)。
若时钟中断频率为 60HZ ,试问 CPU用于时钟中断处理的时间比率为多少?答:因时钟中断频率为60HZ,所以,时钟周期为:l / 60s = 50/3ms。
在每个时钟周期中,CPU花2ms执行中断任务。
所以,CPU用于时钟中断处理的时间比率为:2(50/3)=6/50 = 12%。
第二章处理器管理1.下列指令中哪些只能在核心态运行?(l )读时钟日期; (2 )访管指令; (3 )设时钟日期; (4 )加载 PSW;(5 )置特殊寄存器: (6 )改变存储器映象图; (7 )启动 I/O 指令。
答:(3),(4),(5),(6),(7).2 假设有一种低级调度算法是让“最近使用处理器较少的进程”运行,试解释这种算法对“ I/O 繁重”型作业有利,但并不是永远不受理“处理器繁重”型作业。
答:因为 I/O 繁忙型作业忙于 I/O ,所以它 CPU 用得少,按调度策略能优先执行。
同样原因一个进程等待 CPU足够久时,由于它是“最近使用处理器较少的进程” ,就能被优先调度,故不会饥饿。
3并发进程之间有什么样的相互制约关系?下列日常生活中的活动是属哪种制约关系: (1 )踢足球, (2 )吃自助餐, (3 )图书馆借书, (4 )电视机生产流水线工序。
答:并发进程之间的基本相互制约关系有互斥和同步两种。
其中(1)、(3)为互斥问题. (2 )、 (4 )为同步问题。
4 在按动态优先数调度进程的系统中,每个进程的优先数需定时重新计算。
在处理器不断地在进程之间交替的情况下,重新计算进程优先数的时间从何而来?答:许多操作系统重新计算进程的优先数在时钟中断处理例程中进行,由于中断是随机碰到哪个进程,就插入哪个进程中运行处理程序,并把处理时间记在这个进程的账上。
5 若后备作业队列中等待运行的同时有三个作业 J1 、J2、J3 ,已知它们各自的运行时间为 a 、b 、 c,且满足 a < b <c,试证明采用短作业优先算法调度能获得最小平均作业周转时间。
答:采用短作业优先算法调度时,三个作业的总周转时间为:Tl = = a + ( a +b ) + ( a + b + c ) = 3a + 2b + c①J2、 J1、J3。
则若不按短作业优先算法调度,不失一般性,设调度次序为:三个作业的总周转时间为:T2=b+(b +a )+(b+a + c ) = 3b + 2a + c②令② - ①式得到:T2 - Tl = b- a> 0可见,采用短作业优先算法调度才能获得最小平均作业周转时间。
6、若有一组作业 J1 ,, ,Jn ,其执行时间依次为S1 ,, , Sn 。