Virtual Memory Management
- 29Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is the primary motivation for using virtual memory?
29 questions
- 1
What is the primary motivation for using virtual memory?
Model answer
Virtual memory allows a process to have a logical memory space larger than the available physical memory, enabling more processes to run simultaneously and improving CPU utilization.
Explanation
The lecture explains that virtual memory lets us pretend to have unlimited memory, only bringing in needed parts, which increases multiprogramming and CPU utilization.
- 2
How does virtual memory improve system performance?
Model answer
Virtual memory improves performance by loading only the necessary pages of a program, reducing startup time and allowing more processes to reside in memory concurrently.
Explanation
The lecturer mentions that not loading the entire program speeds up getting started and allows more processes to run, increasing CPU utilization.
- 3
What is the difference between a page and a frame in virtual memory?
Model answer
A page is a fixed-size block of virtual memory, while a frame is a fixed-size block of physical memory of the same size.
Explanation
The lecture states that virtual memory and physical memory are split into pages and frames respectively.
- 4
What is the role of a page table in virtual memory?
Model answer
The page table maps virtual pages to physical frames and stores a valid/invalid bit to indicate whether a page is in memory.
Explanation
The lecture describes the page table as a map that tracks which virtual pages are in real memory and which are on disk.
- 5
What is swap space and how is it related to virtual memory?
Model answer
Swap space is dedicated disk space used to store pages that are not currently in physical memory, enabling virtual memory.
Explanation
The lecturer explains that swap space is how virtual memory is enabled, and that a process is stored entirely in swap space with only needed parts in physical memory.
- 6
How are code, heap, and stack typically arranged in a process's virtual address space?
Model answer
Code and data start at the bottom and grow upward, while the stack starts at the top and grows downward, leaving space in the middle for growth.
Explanation
The lecture mentions that programs start code and data at different ends to leave space, and as data grows it takes extra frames.
- 7
What is demand paging?
Model answer
Demand paging is a technique where pages are loaded into memory only when they are needed (on demand), rather than loading the entire process at startup.
Explanation
The lecturer introduces demand paging as bringing things in only as needed, contrasting with traditional whole-process loading.
- 8
What is a page fault?
Model answer
A page fault occurs when a process accesses a page that is not currently in physical memory, causing the OS to retrieve it from disk.
Explanation
The lecture defines a page fault as an attempt to load a page that is invalid (not in memory), requiring it to be brought in.
- 9
Describe the steps the operating system performs to handle a page fault.
Model answer
The OS traps the page fault, checks that the reference is valid, finds a free frame, reads the needed page from disk into that frame, updates the page table, and restarts the instruction.
Explanation
The lecture walks through the process: page fault trap, check validity, find free frame, schedule I/O to disk, update page table, restart instruction.
- 10
What happens to the process during a page fault?
Model answer
The process is moved to a wait queue until the page is loaded into memory, then it goes to the ready queue to resume execution.
Explanation
The lecturer compares it to process swapping: the process stores its state and waits until I/O completes.
- 11
What is pure demand paging?
Model answer
Pure demand paging starts a process with no pages loaded; the first instruction causes a page fault, which loads the required page.
Explanation
The lecture describes it as not bringing in anything initially, waiting for the first instruction to cause a fault.
- 12
Why might a single instruction cause multiple page faults?
Model answer
An instruction may reference multiple pages (e.g., instruction page and data pages), each of which may need to be loaded individually.
Explanation
The lecturer gives an example of an ADD instruction needing up to three pages (instruction and two data operands) if they reside in different pages.
- 13
What is locality of reference and how does it affect page faults?
Model answer
Locality of reference means programs tend to access the same set of pages repeatedly, reducing the number of page faults.
Explanation
The lecture mentions that code tends to stay in loops or blocks, so pages are reused often.
- 14
Write the formula for effective access time (EAT) in a demand-paged system.
Model answer
EAT = (1 - p) × memory access time + p × page fault time, where p is the probability of a page fault.
Explanation
The lecture presents this equation to show how page faults slow down the system.
- 15
What is thrashing?
Model answer
Thrashing is a condition where the system spends most of its time swapping pages in and out of memory instead of executing processes, leading to severe slowdown.
Explanation
The lecturer describes thrashing as spending all time swapping and very little doing actual work.
- 16
How can adding more physical memory reduce thrashing?
Model answer
More physical memory provides more frames, allowing more pages to remain resident and reducing page faults, thus decreasing thrashing.
Explanation
The lecture notes that adding real memory reduces page faults because you can keep more pages in memory.
- 17
What is the working set of a process?
Model answer
The working set is the set of pages that a process is currently using or has recently referenced, often defined as the pages accessed in a fixed window of time.
Explanation
The lecturer defines it as the bits of memory actually being used by a process at a given time.
- 18
How does the working set model relate to thrashing?
Model answer
If the total working set of all processes exceeds the available physical memory, thrashing occurs because pages must be constantly swapped in and out.
Explanation
The lecture states that when the working set is larger than memory, thrashing results.
- 19
What is one method to prevent thrashing?
Model answer
Suspend one or more processes to reduce the total working set until it fits in memory.
Explanation
The lecture suggests suspending a process to free up memory and stop thrashing.
- 20
What is page fault frequency control?
Model answer
It is a technique where if the page fault rate exceeds a threshold, new processes are suspended or prevented from starting until the rate drops.
Explanation
The lecturer mentions setting an acceptable page fault frequency and pausing processes if it gets too high.
- 21
What is a dirty bit and why is it useful?
Model answer
A dirty bit indicates whether a page has been modified since it was loaded. If a page is not dirty, it can be discarded without writing back to disk during replacement.
Explanation
The lecture explains the dirty bit to avoid unnecessary I/O when swapping out pages that haven't changed.
- 22
Describe the FIFO page replacement algorithm.
Model answer
FIFO replaces the page that has been in memory the longest, regardless of how often it is used.
Explanation
The lecture explains FIFO as swapping out the page that came in first, using a simple queue order.
- 23
What is Belady's anomaly?
Model answer
Belady's anomaly is a phenomenon where increasing the number of frames can cause more page faults under FIFO replacement.
Explanation
The lecture shows that adding more frames can paradoxically increase page faults for certain reference strings.
- 24
Describe the Optimal page replacement algorithm.
Model answer
Optimal replaces the page that will not be used for the longest time in the future. It is used as a theoretical benchmark.
Explanation
The lecture states optimal requires future knowledge and is used to evaluate other algorithms.
- 25
Describe the Least Recently Used (LRU) page replacement algorithm.
Model answer
LRU replaces the page that has been used least recently, assuming that past usage predicts future usage.
Explanation
The lecturer explains LRU as swapping out the page that has not been used in the longest time.
- 26
How can LRU be implemented efficiently?
Model answer
LRU can be implemented using a stack (double linked list) where the most recently used page is at the top and the least recently used at the bottom.
Explanation
The lecture mentions a stack with double linked list to organize pages by recency of use.
- 27
Why is LRU considered better than FIFO?
Model answer
LRU avoids Belady's anomaly and typically results in fewer page faults than FIFO because it uses usage history rather than just arrival time.
Explanation
The lecture shows that LRU yields fewer page faults than FIFO (12 vs 15 in the example) and does not suffer from Belady's anomaly.
- 28
What is clustering in the context of demand paging?
Model answer
Clustering means loading multiple contiguous pages at once when a page fault occurs, exploiting locality to reduce future page faults.
Explanation
The lecture mentions that if you need page one, you might bring in pages 2, 3, and 4 as well, because they are likely to be needed soon.
- 29
How does Windows manage virtual memory?
Model answer
Windows uses demand paging with clustering, maintains minimum and maximum working set sizes for processes, and trims working sets when free memory is low.
Explanation
The lecture describes Windows' approach: demand paging with clustering, min/max working set, and trimming when free memory falls.

Ask anything
We've read this whole study set, so questions about it get the best answers.