Chapter 5: Q11E (page 490)
Question: As described in Section 5.7, virtual memory uses a page table to track the mapping of virtual addresses to physical addresses. This exercise shoes how this table must be updated as addresses are accessed. The following data constitutes a stream of virtual addresses as seen on a system. Assume 4 KiB pages, a 4-entry fully associative TLB, and true LRU replacement. If pages must be brought in from disk, increment the next largest page number.
4669, 2227, 13916, 34587, 48870, 12608, 49225
TLB
Valid | Tag | Physical Page Number |
1 | 11 | 12 |
1 | 7 | 4 |
1 | 3 | 6 |
0 | 4 | 9 |
Page table
Valid | Physical Page or in Disk |
1 | 5 |
0 | Disk |
0 | Disk |
1 | 6 |
1 | 9 |
1 | 11 |
0 | Disk |
1 | 4 |
0 | Disk |
0 | Disk |
1 | 3 |
1 | 12 |
(5.11.1) Given the address stream shown, and the initial TLB and page table states provided above, show the final state of the system. Also list for each reference if it is a hit in the TLB, a hit in the page table, or a page fault.
(5.11.2) Repeat 5.11.1, but this time use 16 KiB pages instead of 4 KiB pages. What would be some of the advantages of having a larger page size? What are some of the disadvantages?
(5.11.3) Show the final contents of the TLB if it is 2-way set associative. Also show the contents of the TLB if it is direct mapped. Discuss the importance of having a TLB to high performance. How would virtual memory accesses be handles if there were no TLB?
There are several parameters that impact the overall size of the page table. Listed below are key page parameters.
Virtual Address Size | Page Size | Page Table Entry Size |
32 bits | 8 KiB | 4 bytes |
(5.11.4) Given the parameters shown above, calculate the total page table size for a system running 5 applications that utilize half of the memory available.
(5.11.5) Given the parameters shown above, calculate the total page table size for a system running 5 applications that utilize half of the memory available, given a two level page table approach with 256 entries. Assume each entry of the main page table is 6 bytes. Calculate the minimum amount of memory required.
(5.11.6) A cache designer wants to increase the size of a 4 KiB virtually indexed, physically tagged cache. Given the page size shown above, is it possible to make a 16 KiB direct-mapped cache, assuming 2 words per block? How would the designer increase the data size of the cache?
Short Answer
(5.11.1)
The final state of the system is:
Valid | Tag | Physical Page Number |
1 | 12 | 15 |
1 | 8 | 14 |
1 | 3 | 6 |
1 | 11 | 12 |
(5.11.2)
The final state of the system is:
Valid | Tag | Physical Page Number |
1 | 2 | 13 |
1 | 7 | 4 |
1 | 3 | 6 |
1 | 0 | 5 |
The advantage is a decrease in TLB miss and the disadvantage is more fragmentation.
(5.11.3)
The content of TLB for 2-way set associative:
Valid | Tag | Index | Physical Page Number |
1 | 6 | 0 | 15 |
1 | 1 | 1 | 6 |
1 | 4 | 0 | 14 |
1 | 5 | 1 | 11 |
The final content for direct-mapped TLB is:
Valid | Tag | Index | Physical Page Number |
1 | 3 | 0 | 15 |
1 | 0 | 1 | 13 |
1 | 3 | 2 | 6 |
1 | 0 | 3 | 6 |
(5.11.4)
The total page table size is 5 MB.
(5.11.5)
The minimum amount of memory for the two-level page table approach is 5MB + 3840 bytes. The maximum amount of memory for the two-level page table approach is 10MB + 7680 bytes.
(5.11.6)
The size of the cache can be increased using a 2-way set associative. It is not possible to use direct-mapped.