操作系统精髓与设计原理第五版课后题答案.doc_第1页
操作系统精髓与设计原理第五版课后题答案.doc_第2页
操作系统精髓与设计原理第五版课后题答案.doc_第3页
操作系统精髓与设计原理第五版课后题答案.doc_第4页
操作系统精髓与设计原理第五版课后题答案.doc_第5页
已阅读5页,还剩15页未读 继续免费阅读

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Chapter 2Operating System OverviewReview Questions2.1Convenience: An operating system makes a computer more convenient to use. Efficiency: An operating system allows the computer system resources 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 system functions without interfering with service.2.5The execution context, or process state, is the internal data by which the 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.1The answers are the same for (a) and (b). Assume that although processor operations cannot overlap, I/O operations can.1 Job:TAT=NTProcessor utilization=50%2 Jobs:TAT=NTProcessor utilization=100%4 Jobs:TAT=(2N 1)NTProcessor utilization=100%2.4A system call is used by an application program to invoke a function provided by the operating system. Typically, the system call results in transfer to a system program that runs in kernel mode.Chapter 3Process Description and ControlReview Questions3.5Swapping involves moving part or all of a process from main memory to 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.10The user mode has restrictions on the instructions that can be executed 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.1Creation and deletion of both user and system processes. The processes 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 processs 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 mechanism for process synchronization. Cooperating processes may share data. Concurrent access to shared data may result in data inconsistency. OS has to provide mechanisms for processes synchronization to ensure the orderly execution of cooperating processes, so that data consistency is maintained.Provision of mechanism for process communication. The processes executing under the OS may be either independent processes or cooperating processes. Cooperating processes must have the means to communicate with each other.Provision of mechanisms for deadlock handling. In a multiprogramming environment, several processes may compete for a finite number of resources. If a deadlock occurs, all waiting processes will never change their waiting state to running state again, resources are wasted and jobs will never be completed.3.3 Figure 9.3 shows the result for a single blocked queue. The figure readily generalizes to multiple blocked queues.Chapter 4Process Description and ControlReview Questions4.2Less state information is involved.4.5Address space, file resources, execution privileges are examples.4.61. Thread switching does not require kernel mode privileges because all 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 may benefit 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 any operating 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.2 Because, with ULTs, the thread structure of a process is not visible to the operating system, which only schedules on the basis of processes.Chapter 5Concurrency: Mutual Exclusion and SynchronizationReview Questions5.1Communication among processes, sharing of and competing for resources, synchronization of the activities of multiple processes, and allocation of processor time to processes.5.9A binary semaphore may only take on the values 0 and 1. A general semaphore may take on any integer value.Problems5.2ABCDE; ABDCE; ABDEC; ADBCE; ADBEC; ADEBC;DEABC; DAEBC; DABEC; DABCE5.5 Consider the case in which turn equals 0 and P(1) sets blocked1 to true and then finds blocked0 set to false. P(0) will then set blocked0 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.Chapter 6Concurrency: Deadlock and StarvationReview Questions6.2Mutual exclusion. Only one process may use a resource at a time. Hold and 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.3The above three conditions, plus: Circular wait. A closed chain of processes exists, such that each process holds at least one resource needed by the next process in the chain.Problems6.4a.0 0 0 0 0 7 5 0 6 6 2 2 2 0 0 2 0 3 2 0b. to d.Running the bankers algorithm, we see processes can finish in the order p1, p4, p5, p2, p3.e.Change available to (2,0,0,0) and p3s 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 p3s still needs can be satisfied. So it is not safe to grant p3s 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 detectedChapter 7Memory ManagementReview Questions7.1 Relocation, protection, sharing, logical organization, physical organization.7.7A logical address is a reference to a memory location independent of the 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.6a.The 40 M block fits into the second hole, with a starting address of 80M. The 20M block fits into the first hole, with a starting address of 20M. The 10M block is placed at location 120M.b.The three starting addresses are 230M, 20M, and 160M, for the 40M, 20M, and 10M blocks, respectively.c.The three starting addresses are 80M, 120M, and 160M, for the 40M, 20M, and 10M blocks, respectively.7.12a.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 main memory)/(210 bytes/frame) = 222 frames. So 22 bits is needed to specify 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 the frame location in main memory, for a total of 23 bits.d.The three starting addresses are 80M, 230M, and 360M, for the 40M, 20M, and 10M blocks, respectively.Chapter 8Virtual MemoryReview Questions8.1Simple paging: all the pages of a process must be in main memory for process 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 spends most of its time swapping pieces rather than executing instructions.Problems8.1a.Split binary address into virtual page number and offset; use VPN as index into page table; extract page frame number; concatenate offset 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.4a.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 oldest loaded), victim PFN is 0 since R=0d.Replace the page in PFN 3 since VPN 3 (in PFN 3) is used furthest in the futuree.There are 6 faults, indicated by *4000*2*42*1*0*32VPN of pages in memory in LRU order302143020430430420420240124012430122Chapter 9Uniprocessor SchedulingReview Questions9.1Long-term scheduling: The decision to add to the pool of processes to be executed. Medium-term scheduling: The decision to add to the number of processes that are partially or fully in main memory. Short-term scheduling: The decision as to which available process will be executed by the processor9.3Turnaround time is the total time that a request spends in the system (waiting time plus service time. Response time is the elapsed time between the submission of a request until the response begins to appear as output.Problems9.1Each square represents one time unit; the number in the square refers to the currently-running process.FCFSAAABBBBBCCDDDDDEEEEERR, q = 1ABABCABCBDBDEDEDEDEERR, q = 4AAABBBBCCBDDDDEEEEDESPNAAACCBBBBBDDDDDEEEEESRTAAACCBBBBBDDDDDEEEEEHRRNAAABBBBBCCDDDDDEEEEEFeedback, q = 1ABACBCABBDBDEDEDEDEEFeedback, q = 2iABAACBBCBBDDEDDEEDEEABCDETa013912Ts35255FCFSTf38101520Tr3.007.007.006.008.006.20Tr/Ts1.001.403.501.201.601.74RR q = 1Tf6.0011.008.0018.0020.00Tr6.0010.005.009.008.007.60Tr/Ts2.002.002.501.801.601.98RR q = 4Tf3.0010.009.0019.0020.00Tr3.009.006.0010.008.007.20Tr/Ts1.001.803.002.001.601.88SPNTf3.0010.005.0015.0020.00Tr3.009.002.006.008.005.60Tr/Ts1.001.801.001.201.601.32SRTTf3.0010.005.0015.0020.00Tr3.009.002.006.008.005.60Tr/Ts1.001.801.001.201.601.32HRRNTf3.008.0010.0015.0020.00Tr3.007.007.006.008.006.20Tr/Ts1.001.403.501.201.601.74FB q = 1Tf7.0011.006.0018.0020.00Tr7.0010.003.009.008.007.40Tr/Ts2.332.001.501.801.601.85FBTf4.0010.008.0018.0020.00q = 2iTr4.009.005.009.008.007.00Tr/Ts1.331.802.501.801.601.819.16a.Sequence with which processes will get 1 min of processor time:12345Elapsed timeAAAAAAAAAAAAAAABBBBBBBBBCCCDDDDDDEEEEEEEEEEEE51015192327303336384042434445 The turnaround time for each process: A = 45 min, B = 35 min, C = 13 min, D = 26 min, E = 42 min The average turnaround time is = (45+35+13+26+42) / 5 = 32.2 minb.PriorityJobTurnaround Time34679BEACD99 + 12 = 2121 + 15 = 3636 + 3 = 3939 + 6 = 45The average turnaround time is: (9+21+36+39+45) / 5 = 30 minc.JobTurnaround TimeABCDE1515 + 9 = 2424 + 3 = 2727 + 6 = 3333 + 12 = 45The average turnaround time is: (15+24+27+33+45) / 5 = 28.8 mind.Running TimeJobTurnaround Time3691215CDBEA33 + 6 = 99 + 9 = 1818 + 12 = 3030 + 15 = 45The average turnaround time is: (3+9+18+30+45) / 5 = 21 minChapter 10Multiprocessor and Real-Time SchedulingReview Questions10.1Fine: Parallelism inherent in a single instruction stream. Medium: Parallel processing or multitasking within a single application. Coarse: Multiprocessing of concurrent processes in a multiprogramming environment. Very Coarse: Distributed processing across network nodes to form a single computing environment. Independent: Multiple unrelated processes.10.4A hard real-time task is one that must meet its deadline; otherwise it will cause undesirable damage or a fatal error to the system. A soft real-time task has an associated deadline that is desirable but not mandatory; it still makes sense to schedule and complete the task even if it has passed its deadline.Problems10.1For fixed priority, we do the case in which the priority is A, B, C. Each square represents five time units; the letter in the square refers to the currently-running process. The first row is fixed priority; the second row is earliest deadline scheduling using completion deadlines.AABBAACCAABBAACCAAAABBACCACAABBAACCCAAFor fixed priority scheduling, process C always misses its deadline.10.4Once T3 enters its critical section, it is assigned a priority higher than T1. When T3 leaves its critical section, it is preempted by T1.Chapter 11I/O Management and Disk SchedulingReview Questions11.1Programmed 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 module controls the exchange of data between main memory and an I/O module. The processor sends a request for the transfer of a block of data to the DMA module and is interrupted only after the entire block has been transferred.11.5Seek time, rotational delay, access time.Problems11.1If the calculation time exactly equals the I/O time (which is the most favorable situation), both the processor and the peripheral device running 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 time with 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.3Disk head is initially moving in the direction of decreasing track number:FIFOSSTFSCANC-SCANNext track accessedNumber of tracks traversedNext track accessedNumber of tracks traversedNext track accessedNumber of tracks traversedNext track accessedNumber of tracks traversed2773110106436643612910212010412341231101912992714271418676147181017101714739186391101001861764110664122120101473910314123129912918645427141471812091205610171863911010Average61.8Average29.1Average29.6Average38If the disk head is initially moving in the direction of increasing track number, only the SCAN and C-SCAN results change:SCANC-SCANNext track accessedNumber of tracks traversedNext track accessedNumber of tracks traversed1101011010120101201012991299147181471818639186396412210176412327172714411410176423Average29.1Average35.1Chapter 12File ManagementR

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论