Section 3.7 Page Swapping
In this section we discuss the process of storing unused pages to a disk, increase the amount of perceived memory available to processes. This is covered in two chapters. Start with [chapter 21](https://pages.cs.wisc.edu/~remzi/OSTEP/vm-beyondphys.pdf). In particular sections 21.1, 21.2.
Practice 3.7.1.
What is the purpose of the
present bit?
It says whether the page can be found in the TLB.
-
It says that this page is used by the process and its information is currently in disk.
-
It says that this page is currently in memory in the location indicated by the PTE.
-
Read section 21.3, on page faults.
Practice 3.7.2.
True or False: If the present bit is 0, meaning the page is not in memory but only in disk, then we use the space of the PTE where the PFN is normally stored to instead store the disk location of the page.
True.
-
False.
-
Practice 3.7.3.
True or False: While a page fault is being serviced, the process is considered to be in the blocked state.
True.
-
False.
-
Read section 21.4 describing the overall process for what happens when a page fault occurs.
Practice 3.7.4.
Open-ended: Describe the overall process for handling a request for a memory address. It should roughly include these steps:
-
Look in the TLB.
-
If TLB miss, look in the page table for the PTE.
-
If PTE is invalid error (or allocate new block).
-
If PTE is valid but not present, initiate page swap.
-
If PTE is valid and present, return entry.
-
For the allocate or page swap cases:
-
Look for free physical location in memory. If found, allocate or load.
-
If not found, evict a page then allocate/load in its place.
Skim through sections 21.6 and 21.7.
Start on
chapter 22 on policies governing page-swapping. The overall question is how to decide which page to evict. Read section 22.1 which discusses the
average memory access time measure (
AMAT). Try some examples with different numbers.
Read section 22.2 about the theoretically optimal replacement policy.
Practice 3.7.5.
What is the choice made by the optimal policy, in terms of which page to evict?
If we could look at future accesses, we want the page that is accessed for the first time furthest in the future.
-
If we could look at future accesses, we want the page that is accessed the fewest times in the future.
-
If we look at past accesses, we want the page that has been accessed least recently.
-
If we look at past accesses, we want the page that has been accessed fewer times.
-
Practice 3.7.6.
True or False: Cold start misses can be avoided if we are clever about how we store and swap pages.
True.
-
False.
-
Skim through sections 22.3 and 22.4 which discuss two inferior approaches: FIFO and random.
Practice 3.7.7.
True or False: When using FIFO page eviction policy, there are situations where increasing the cache size may lead to a decreased cache hit rate and performancee.
True.
-
False.
-
Read sections 22.5 and 22.6 about the LFU and LRU eviction policies.
Practice 3.7.8.
True or False: The effectiveness of these LFU and LRU policies relies on the principle of locality.
True.
-
False.
-
Skim through the remaining sections of chapter 22. Sections 22.7 and 22.8 discuss how to perform approximate LRU efficiently. Section 22.9 discusses what needs to change if a page that is in memory has some changes compared to the version stored on disk. Section 22.11 discusses the problem of thrashing. Section 22.12 is a summary.
You have attempted
of
activities on this page.