Unit 9 · Self-check
Unit 9 Self-Check Quiz
Twenty-five questions covering paging, multi-level page tables, the TLB, demand paging, page faults, page-replacement algorithms, and thrashing. Each question can be expanded to reveal a model answer.
Questions
Multiple choice and short answer
Answer each question before expanding. These span all seven lessons of Unit 9.
Question 1
Given a 4 KB page size and a 32-bit virtual address, how many bits are used for the page number and how many for the offset? How large is a single-level page table if each entry is 4 bytes?
Show answer
Question 2
Translate the virtual address 0x00003A7C to a physical address given the page table:
Page Frame
0 4
1 7
2 2
3 5
Show answer
Question 3
What is a multi-level page table, and what problem does it solve?
Show answer
Question 4
What is the TLB, and why is it important for performance?
Show answer
Question 5
Why do huge pages (2 MB or 1 GB) improve performance for large working sets?
Show answer
Question 6
What is demand paging, and what is the alternative?
Show answer
Question 7
Describe the steps the kernel performs to handle a page fault.
Show answer
- The MMU detects that the page table entry for the accessed address is invalid and raises a page-fault trap.
- The kernel saves the faulting instruction's state (program counter, registers) so that the instruction can be restarted.
- The kernel checks whether the reference is legal. If the address is not in the process's address space, or the access violates the page's protection, the kernel delivers
SIGSEGVand the process terminates. - If the page is legal, the kernel locates the page on backing store (or in the page cache).
- If no free frame is available, the kernel selects a victim page via the replacement algorithm and writes it back to backing store if it is dirty.
- The kernel reads the required page into the free frame. For a minor fault (the page is already in memory but not mapped), it simply maps the existing physical page into the process's page table.
- The kernel updates the page table entry with the frame number and the valid bit.
- The kernel returns from the trap, and the CPU restarts the faulting instruction. This time, the translation succeeds.
Question 8
What is the difference between a minor and a major page fault?
Show answer
fork) but the page-table entry for this process is not yet established. The handler simply updates the page table; no I/O is required. A major fault occurs when the page must be read from backing store (disk or swap). The handler must issue I/O, block the faulting process, and resume it when the I/O completes. A major fault costs thousands of times more than a minor fault. The ratio of minor to major faults is a useful indicator of the memory pressure on the system: a sudden increase in major faults often signals that a working set no longer fits in memory.
Question 9
What does it mean for a page to be "dirty"? Why does the kernel track this?
Show answer
Question 10
A system has three frames and the reference string is 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5. Compute the number of page faults under FIFO with 3 frames and with 4 frames. What does this demonstrate?
Show answer
1: F [1]
2: F [1 2]
3: F [1 2 3]
4: F evict 1 → [4 2 3]
1: F evict 2 → [4 1 3]
2: F evict 3 → [4 1 2]
5: F evict 4 → [5 1 2]
1: H [5 1 2]
2: H [5 1 2]
3: F evict 5 → [3 1 2]
4: F evict 1 → [3 4 2]
5: F evict 2 → [3 4 5]
Faults: 9.
FIFO with 4 frames:
1: F [1]
2: F [1 2]
3: F [1 2 3]
4: F [1 2 3 4]
1: H [1 2 3 4]
2: H [1 2 3 4]
5: F evict 1 → [5 2 3 4]
1: F evict 2 → [5 1 3 4]
2: F evict 3 → [5 1 2 4]
3: F evict 4 → [5 1 2 3]
4: F evict 5 → [4 1 2 3]
5: F evict 1 → [4 5 2 3]
Faults: 10. More frames produced more faults. This is Belady's anomaly, a counter-intuitive property of FIFO. It arises because FIFO does not satisfy the stack property: the set of pages retained with n+1 frames is not always a superset of the set retained with n frames.
Question 11
Explain the Optimal page-replacement algorithm. Why is it not implementable in a real system, and why is it still useful?
Show answer
Question 12
Why is exact LRU difficult to implement, and what approximation do real systems use?
Show answer
Question 13
Describe the Clock (second-chance) page-replacement algorithm.
Show answer
- The hand checks the reference bit of the current frame.
- If the bit is 0, the frame is evicted; the hand moves to the next frame.
- If the bit is 1, the algorithm clears it (giving the page a "second chance") and advances the hand.
Question 14
What is thrashing, and what are its symptoms?
Show answer
Question 15
Describe the working-set model and the page-fault-frequency policy for controlling thrashing.
Show answer
Question 16
A system has a page-fault service time of 8 ms and a memory access time of 200 ns. If the page-fault rate is 1 in 10,000 accesses, what is the effective access time?
Show answer
Question 17
A system uses 4 frames and the reference string 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2. Compute the faults under LRU.
Show answer
7: F [7]
0: F [7 0]
1: F [7 0 1]
2: F [7 0 1 2]
0: H [0 7 1 2]
3: F evict 7 (LRU) → [3 0 1 2]
0: H [0 3 1 2]
4: F evict 1 (LRU) → [4 0 3 2]
2: H [2 4 0 3]
3: H [3 2 4 0]
0: H [0 3 2 4]
3: H [3 0 2 4]
2: H [2 3 0 4]
Faults: 6. (The first four references are cold misses; the next two are the only replacements, and the remaining references all hit.)
Question 18
What is the working set of a process, and why is it the correct abstraction for thinking about thrashing?
Show answer
Question 19
What is a copy-on-write page, and how does it reduce the cost of fork?
Show answer
fork) and marked read-only in both page tables. As long as both processes only read the page, they share the same physical frame — no copy is made. When either process writes to the page, the MMU raises a protection fault, and the kernel allocates a new frame, copies the page's content, and updates the writer's page table so that the write can proceed. The other process continues to share the original frame. COW reduces the cost of fork because the parent's entire address space is not duplicated at fork time; only pages that are subsequently written are copied. Since many children immediately call exec (which discards the copied address space), the copy is often never made at all.
Question 20
What is the difference between the resident set of a process and its working set?
Show answer
Question 21
Explain the difference between global and local page replacement.
Show answer
Question 22
What is the difference between a page fault and a protection fault?
Show answer
SIGSEGV and terminates the process. The two faults are distinguished by the page-table entry's state and by the hardware's error code: a present-but-protected page raises a protection fault, while a not-present page raises a page fault. (Copy-on-write pages blur the distinction: they are present but read-only, so a write raises a protection fault that the kernel handles by copying rather than by killing the process.)
Question 23
Why does the effective access time formula include a term for the page-fault service time, and why is the fault rate so important?
Show answer
Question 24
What does Linux's /proc/<pid>/smaps show, and how is it useful for understanding a process's memory behaviour?
Show answer
/proc/<pid>/smaps reports, for each memory region of a process, the region's size, the resident set size (RSS), the proportional set size (PSS), the shared/private clean and dirty page counts, and the kernel's accounting of swapped pages. It is useful for understanding memory behaviour because it distinguishes:
- Resident pages (in physical memory) from virtual pages (mapped but not necessarily resident).
- Shared pages (mapped into several processes) from private pages.
- Clean pages (backed by a file, can be discarded) from dirty pages (modified, must be written back).
- Anonymous pages (heap, stack,
mmapwithout a file) from file-backed pages (executable, libraries, mapped files).
Question 25
In one or two sentences, state the central insight that makes virtual memory work despite the enormous cost of a page fault.
Show answer
Ready for the graded quiz?
Once you are comfortable with every question above, take the graded Unit 9 quiz in the LMS. It covers the same material with multiple-choice questions, address-translation exercises, and page-replacement computations similar to Questions 10 and 17.