1、操作系统精髓与设计原理第五版 课后题答案Chapter 2Operating System OverviewReview Questions2.1 Convenience: 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
2、 constructed in such a way as to permit the effective development, testing, and introduction of new system functions without interfering with service.2.5 The execution context, or process state, is the internal data by which the operating system is able to supervise and control the process. This int
3、ernal 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 incl
4、udes 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 answe
5、rs are the same for (a) and (b). Assume that although processor 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 prog
6、ram 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.5 Swapping involves moving part or all of a process from main memory to disk. When none of
7、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 executed and the memo
8、ry 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. The processes in the system c
9、an 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
10、 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 sta
11、te 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 coop
12、erating 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 mecha
13、nisms 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.3Figure 9.
14、3 shows the result for a single blocked queue. The figure readily generalizes to multiple blocked queues.Chapter 4Process Description and ControlReview Questions4.2 Less state information is involved.4.5 Address space, file resources, execution privileges are examples.4.6 1. Thread switching does no
15、t 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
16、 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
17、 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.7 1. In a typical operating system, many system calls are blocking. Thus, when a ULT execute
18、s 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
19、 within a process can execute at a time. Problems4.2Because, 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.1 Communication among processes
20、, sharing of and competing for resources, 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 general semaphore may take on any integer value.Problems5.2 ABCDE; ABDCE; ABDEC; ADBCE; ADBEC
21、; ADEBC; DEABC; DAEBC; DABEC; DABCE5.5Consider 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 sec
22、tion.Chapter 6Concurrency: Deadlock and StarvationReview Questions6.2 Mutual 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
23、it.6.3 The 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.4 a. 0 0 0 0 0 7 5 0 6 6 2 2 2 0 0 2 0 3 2 0 b. to d. Running the bankers algorithm, we see processes can f
24、inish 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.5 1. W = (2 1 0 0) 2. Mark P3; W = (2
25、 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.7 A logical address is a reference to a memory location indep
26、endent 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 begi
27、nning 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 of 80M. The 20M block fits into the first hole, with a starting address of 20M. The 10M block is placed at location 120
28、M. 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.12 a. The number of bytes in the logical address space is (216 pages) (210 bytes/page)
29、 = 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
30、 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.Ch
31、apter 8Virtual MemoryReview Questions8.1 Simple 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.2 A phenome
32、non in virtual memory schemes, in which the processor spends most of its time swapping pieces rather than executing instructions.Problems8.1 a. 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 address b. (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
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1