🎓 BookMCQ
← Back to 9. Virtual Memory

📝 Working set model of thrashing (11 MCQs)

Tracking Recently Referenced Pages in a Working Set

The working-set model is a virtual-memory technique that estimates the pages a process actively uses during a recent interval. It defines a working set using a window of the most recent memory references or an equivalent time-based approximation. The operating system uses this estimate to allocate frames, identify memory demand, and reduce thrashing caused by insufficient resident pages.

Why Recent Memory Locality Determines Frame Requirements

Programs usually exhibit locality, repeatedly accessing a relatively small collection of instructions and data during a particular execution phase. Allocating too few frames for this active collection causes frequent faults. The working-set model attempts to keep the required pages resident while allowing inactive pages to be reclaimed. Its effectiveness depends on the chosen window and changing application behaviour.

Working-Set Window and Page Membership

Let the working-set window be Δ references. The working set WS(t, Δ) contains distinct pages referenced during the most recent Δ memory references at time t. The operating system estimates its size and uses it to guide frame allocation. A larger window captures more historical activity, while a smaller window responds faster to changing locality.

Calculating a Working Set from Recent References

Suppose the last eight references are 1, 2, 1, 3, 4, 2, 5, 3. With a window of eight, the working set contains pages 1, 2, 3, 4, and 5. Its size is five distinct pages. A process may therefore require at least five frames to keep this particular recent collection resident.

Frame Demand and Multiprogramming Control

The operating system can estimate total frame demand by adding the working-set sizes of active processes. If the sum exceeds available physical frames, it may suspend one or more processes to reduce multiprogramming. Suitable allocation protects active locality and lowers fault rates. However, maintaining accurate working-set information introduces monitoring costs, and abrupt phase changes can make historical estimates temporarily inaccurate.

Misunderstandings About Working-Set Size

'The working set contains every page in the executable' is incorrect because it contains recently referenced distinct pages. 'A working set remains constant throughout execution' is incorrect because locality changes between program phases. 'The window counts unique pages directly' is incorrect because it covers a reference interval from which unique page identities are determined.

Exam Focus: Working-Set Calculations and Thrashing Control

Given a reference string and window size, identify all distinct pages in the latest reference interval. Calculate working-set size and total frame demand across processes. Explain how a memory shortage can require process suspension. Compare small and large windows and discuss their effects on responsiveness to changing locality and estimation overhead.

Key Terms of the Working-Set Model

  • Working set - Distinct recently referenced pages.
  • Window Δ - Recent reference interval.
  • Locality - Concentrated memory-access behaviour.
  • Working-set size - Number of distinct active pages.
  • Frame demand - Frames required by processes.
  • Process suspension - Temporarily removes execution.
2
Easy
5
Medium
4
Hard

📝 All Working set model of thrashing MCQs

Q1. What condition triggers a page fault in a paging system?

A.Access to a page that is already resident in memory
B.Access to a page whose invalid bit is set ✅
C.Access to a read‑only page while writing
D.Access to a page that has been swapped out but is still marked valid
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The hardware checks the invalid bit in the page‑table entry; when this bit is set the translation cannot proceed, causing a trap to the OS, which is defined as a page fault. Option B describes this exact situation, so it is correct. Option A describes normal access, which does not fault. Option C would cause a protection fault, not a page fault. Option D would be handled by a replacement algorithm, not by the invalid‑bit check. In practice, the OS relies on this mechanism to bring missing pages into RAM.

Q2. Why must the OS update both the internal process table and the page table after bringing a page into memory?

A.To inform the CPU cache
B.To keep software and hardware views consistent ✅
C.To reset the invalid bit only
D.To allocate a new virtual address
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The internal table (often part of the PCB) records which virtual pages are resident, while the page table is used by the memory‑management hardware. Updating both ensures that the OS’s bookkeeping and the hardware’s translation agree, preventing future faults on the same page. Option B captures this need. Option A is unrelated to paging. Option C mentions only part of the update; the valid bit must also be set. Option D is incorrect because virtual addresses are fixed; the operation only changes residency status. Consistent state lets the process continue without interruption.

Q3. How does pure demand paging affect the total number of page faults compared with a pre‑paging strategy?

A.It always reduces the total faults
B.It increases faults at startup but may lower overall faults ✅
C.It eliminates all faults after the first instruction
D.It causes the same number of faults as pre‑paging
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Pure demand paging loads pages only when they are first accessed, so the first reference to each needed page generates a fault, leading to many faults early in execution. However, pages that are never used are never loaded, potentially reducing the overall fault count compared with pre‑paging, which loads a predetermined set regardless of use. Option B reflects this trade‑off. Option A is false because early faults are higher. Option C is impossible; faults occur on first accesses. Option D ignores the selective loading benefit. Real systems balance the two approaches to minimize I/O while keeping performance acceptable.

Q4. In the working‑set model, how does the size of a process’s working set influence the choice of page‑replacement algorithm?

A.Larger working sets favor FIFO
B.Smaller working sets require NRU
C.Algorithms that preserve recent references are preferred for larger working sets ✅
D.Working‑set size has no impact on algorithm selection
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: The working set represents the pages a process has used recently; a larger working set means more pages must stay resident to avoid thrashing. Replacement algorithms that keep recently referenced pages (e.g., LRU or its approximations) are better suited because they are less likely to evict pages still needed. Option C correctly links working‑set size to algorithm choice. Option A is incorrect because FIFO ignores recent use. Option B misstates NRU’s suitability. Option D is false; the working‑set principle directly guides replacement decisions. In practice, OSes monitor working‑set size to adapt replacement policies dynamically.

Q5. A process requests a new page but the free‑frame list is empty. Which replacement algorithm is most likely to minimize the latency of the ensuing page fault?

A.FIFO
B.LRU ✅
C.Random
D.No replacement (terminate process)
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: When no free frames exist, the OS must evict a page. LRU (or a close approximation) selects the page that has not been used for the longest time, which statistically reduces the chance that the evicted page will be needed again soon, thereby lowering the probability of an immediate second fault and overall latency. Option B therefore best minimizes latency. FIFO may evict a recently used page, increasing future faults. Random provides no guarantee and can be worse. Terminating the process is unnecessary and would waste work. Real systems often use LRU‑like heuristics for this reason.

Q6. If a disk read to fetch a missing page takes 1010 ms and the CPU needs 0.50.5 ms to restart the interrupted instruction, what is the total time spent handling the page fault?

A.10.510.5 ms ✅
B.1010 ms
C.0.50.5 ms
D.1111 ms
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: The total handling time is the sum of the disk I/O latency and the CPU overhead for restarting the instruction. Adding 1010 ms (disk) and 0.50.5 ms (CPU) yields 10.510.5 ms, matching option A. Option B omits the CPU restart cost, option C ignores the dominant disk latency, and option D adds an extra millisecond with no basis. Understanding the components of fault handling helps designers estimate performance impact of paging in real systems, where disk latency typically dominates.

Q7. A process is started with no pages in memory and needs exactly five distinct pages to run. Assuming each first reference causes a fault, how many page faults will occur before the process can execute without further faults?

A.0
B.1
C.5 ✅
D.6
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: With pure demand paging, each of the five distinct pages will be faulted the first time it is accessed, resulting in five faults. After those pages are loaded, subsequent instructions will find their pages resident, so no additional faults occur. Option C correctly counts the five initial faults. Option A would imply no faults, contradicting the definition of demand paging. Option B understates the count, and option D adds an extra fault that does not exist because only five unique pages are needed. This scenario illustrates how demand paging incurs an upfront cost equal to the number of unique pages required.

Q8. Two processes, P1 and P2, each request a new page while the free‑frame list contains only two frames. P1 will need a total of three pages, P2 only one. Which ordering of page loads minimizes the combined fault latency?

A.Load P1’s page first, then P2’s
B.Load P2’s page first, then P1’s ✅
C.Load both simultaneously
D.Delay both until more frames appear
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Loading P2’s single needed page first uses one free frame and completes its execution without further faults, freeing a frame for P1. When P1’s pages are later loaded, only two additional faults are required, reducing the total waiting time compared with loading P1’s pages first, which would still leave P2 needing a fault after frames are occupied. Option B yields the lowest combined latency. Option A causes unnecessary waiting for P2. Option C is impossible because only two frames exist; they cannot be loaded truly simultaneously. Option D merely postpones the inevitable faults and increases total delay.

Q9. If the OS’s internal table incorrectly marks a page as valid when it is actually not resident, what is the most likely immediate outcome when the process accesses that page?

A.The process is terminated instantly
B.The hardware raises a protection fault
C.A page fault occurs ✅
D.The CPU silently reads stale data
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: The internal table is used by the OS for bookkeeping, but the actual translation is performed by the hardware using the page‑table entry. When the page is not resident, the hardware sees the invalid bit set and generates a page fault, regardless of the OS’s mistaken entry. Therefore option C is correct. Option A would only happen after the OS determines the access is illegal, not immediately. Option B describes a protection violation, which is unrelated to residency. Option D would require the page to be present; without it, the CPU cannot read valid data. This scenario shows the importance of synchronizing OS tables with hardware structures.

Q10. How does the working‑set model help an operating system avoid thrashing?

A.By forcing all processes to share a single global working set
B.By dynamically adjusting the number of pages allocated to each process based on recent usage ✅
C.By pre‑loading every page a process might need
D.By ignoring page‑reference patterns and using random replacement
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: The working‑set model monitors the set of pages a process has referenced recently; if the set grows beyond available memory, the OS can reduce the allocation or swap out less‑used pages, preventing excessive paging activity known as thrashing. Option B captures this adaptive behavior. Option A is incorrect because each process maintains its own working set. Option C defeats the purpose of demand paging and can cause thrashing. Option D disregards the model’s purpose. In real systems, the OS uses working‑set information to balance responsiveness and memory pressure.

Q11. A system with a free‑frame list of size two receives page requests from three processes in quick succession. Which scheduling policy best ensures that each process experiences at most one page fault before all frames are occupied?

A.Round‑robin allocation
B.Allocate frames to the process with the smallest working set ✅
C.Give all frames to the first requester
D.Randomly assign frames
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: By giving frames first to the process whose working set is smallest, the OS guarantees that the process will likely need fewer additional pages, limiting it to a single fault before the frames are filled. Option B achieves the goal. Round‑robin (A) may allocate a frame to a process that later needs more pages, causing extra faults. Allocating all frames to the first requester (C) leaves the other processes without any frames, leading to multiple faults later. Random assignment (D) offers no guarantee. This policy reflects practical OS strategies that prioritize processes with lower memory demand to reduce fault frequency.

🔗 Related Topics (MCQs)