操作系统习题课_2
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
• 8.12
– a. N – b. P
• 8.18
– a.
page number (5)
offset (11)
– b. 32 entries, each entry is 9 bits wide. – c. If total number of entries stays at 32 and the page size does not change, then each entry becomes 8 bits wide.
1+26+214=16,449 pages 1+28+214=16,641 pages
8位
6位
8位
10位
8位
8位
6位
10位
1+28+216= 65,973 pages
• 8.12 Consider a page reference string for a process with a working set of M frames, initially all empty. The page reference string is of length P with N distinct page numbers in it. For any page replacement algorithm,
– (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)
– a. What is the format of the processor’s logical address? – b. What is the length and width of the page table (disregarding the “access rights” bits)? – c. What is the effect on the page table if the physical memory space is reduced by half?
习题课(2)
• 7.5 Another placement algorithm for dynamic partitioning is referred to as worst-fit. In this case, the largest free block of memory is used for bringing in a process. Discuss the pros and cons of this method compared to first-, next-, and best-fit. What is the average length of the search for worst-fit? • 7.13 A virtual address a in a paging system is equivalent to a pair (p, w), in which p is a page number and w is a byte number within the page. Let z be the number of bytes in a page. Find algebraic equations that show p and w as functions of z and a.
– a. What is a lower bound on the number of page faults? – b. What is an upper bound on the number of page faults?
• 8.18 Consider a paged logical address space (composed of 32 pages of 2 Kbytes each) mapped into a 1-Mbyte physical memory space.
– a. How many levels of page tables are required? – b. What is the size of the page table at each level? – c. The smaller page size could be used at the top level or the bottom level of the page table hierarchy. Which strategy consumes the least number of pages?
• 8.2 Consider a paged virtual memory system with 32-bit virtual addresses and 1K-byte pages. Each page table entry requires 32 bits. It is desired to limit the page table size to one page.
– – – – a. 0, 198 b. 2, 156 c. 1, 530 d. 3, 444
• a. Segment 0 starts at location 660. With the offset, we have a physical address of 660 + 198 = 858 • b. 222 + 156 = 378 • c. Segment 1 has a length of 422 bytes, so this address triggers a segment fault. • d. 996 + 444 = 1440 • e. 660 + 222 = 882
• Discuss: A criticism of the best fit algorithm is that the space remaining after allocating a block of the required size is so small that in general it is of no real use. The worst fit algorithm maximizes the chance that the free space left after a placement will be large enough to satisfy another request, thus minimizing the frequeBiblioteka Baiducy of compaction. The disadvantage of this approach is that the largest blocks are allocated first; therefore a request for a large area is more likely to fail. • Average search length : s/4; where s is the number of resident segments.
• 9.3 Prove that, among nonpreemptive scheduling algorithms, SPN provides the minimum average waiting time for a batch of jobs that arrive at the same time. Assume that the scheduler must always execute a task if one is available.
• The relationship is a = pz + w, 0 ≤ w < z, which can be stated as:
– p = a/z, the integer part of a/z. – w = Rz(a), the remainder obtained in dividing a by z.
• a. Virtual memory can hold (232 bytes of main memory)/( 210 bytes/page) = 222 pages, so 22 bits are needed to specify a page in virtual memory. Each page table contains (210 bytes per page table)/(4 bytes/entry) = 28 entries. Thus, each page table can handle 8 of the required 22 bits. Therefore, 3 levels of page tables are needed. • b. Tables at two of the levels have 28 entries; tables at one level have 26 entries. (8 +8 + 6 = 22). • c. Less space is consumed if the top level has 26 entries. In that case, the second level has 26 pages with 28 entries each, and the bottom level has 214 pages with 28 entries each, for a total of 1 + 26 + 214 pages = 16,449 pages. If the middle level has 26 entries, then the number of pages is 1 + 28 + 214 pages = 16,641 pages. If the bottom level has 26 entries, then the number of tables is 1 + 28 + 216 pages =65,973 pages.
32位
232B/(1kB/项)=222项
10位
22位
Each page table contains (210 bytes per page table)/(4 bytes/entry) = 28 entries
So, each page table can handle 8 bits
6位 8位 8位 10位
• 7.14 Consider a simple segmentation system that has the following segment table:
Starting Address 660 1752 222 996 Length (bytes) 248 422 198 604
• For each of the following logical addresses, determine the physical address or indicate if a segment fault occurs:
• 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.
• We will prove the assertion for the case in which a batch of n jobs arrive at the same time, and ignoring further arrivals. The proof can be extended to cover later arrivals. • Let the service times of the jobs be t1 ≤ t2 ≤ . . . ≤ tn • Then, n users must wait for the execution of job 1; n – 1 users must wait for the execution of job 2, and so on. Therefore, the average response time is