🎓 BookMCQ
← Back to 9. Virtual Memory

📝 Counting based page replacement (8 MCQs)

Reference Counters for Page Replacement Decisions

Counting-based page replacement uses access-frequency information to select resident pages for removal. The operating system maintains a counter or equivalent frequency estimate for each page and updates it when references occur. Two common approaches are Least Frequently Used, which removes the page with the smallest count, and Most Frequently Used, which removes the page with the largest count.

Why Reference Frequency Can Influence Page Value

A frequently accessed page may contain instructions or data repeatedly required by a workload, making its removal costly. Frequency-based policies attempt to preserve pages with useful access patterns. However, historical frequency does not always predict future behaviour. A page used heavily during an earlier phase may become unnecessary after the program changes to another processing phase.

LFU and MFU Counter-Based Selection

Each resident page receives an access counter that increases whenever the page is referenced, using the implementation's counting rules. Under LFU, the page with the smallest frequency count becomes the victim. Under MFU, the page with the highest count is selected. Additional rules, such as aging or arrival-order tie-breaking, may be required when counts are equal.

Choosing a Victim from Page Reference Counts

Suppose four resident pages have reference counts A = 2, B = 9, C = 4, and D = 1. LFU selects page D because it has the smallest count. MFU selects page B because it has the largest count. These different outcomes demonstrate how the two policies interpret historical access frequency differently.

Frequency Tracking and Changing Workload Phases

Counting-based policies can retain frequently used data, but maintaining counters requires additional storage and update operations. LFU may preserve pages that were popular earlier, while MFU may remove genuinely useful pages because of a high historical count. Aging gradually reduces old frequency information, helping algorithms adapt when application access patterns change.

Common Errors About Frequency-Based Victims

'LFU removes the least recently accessed page' is incorrect because it considers reference frequency rather than recency. 'MFU removes the page with the smallest counter' is incorrect because it selects the largest count. 'A high historical count guarantees future reuse' is incorrect because workload phases and access patterns can change.

Exam Focus: LFU, MFU and Counter Updates

Given page-reference counts, identify the LFU and MFU victims and apply any specified tie-breaking rule. Trace counter updates across a reference sequence. Explain how aging changes historical counts and compare frequency-based policies with LRU and FIFO. Questions may also ask why a page with a high historical frequency can become a poor replacement choice.

Key Terms of Counting-Based Replacement

  • LFU - Removes the least frequently used page.
  • MFU - Removes the most frequently used page.
  • Reference count - Tracks page access frequency.
  • Aging - Reduces the influence of old counts.
  • Tie-breaking - Resolves equal frequency values.
  • Frequency - Number of recorded accesses.
2
Easy
4
Medium
2
Hard

📝 All Counting based page replacement MCQs

Q1. What type of page-replacement algorithm selects the page with the smallest reference count for eviction?

A.Least Recently Used
B.First-In First-Out
C.Least Frequently Used ✅
D.Clock
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: The algorithm that evicts the page with the smallest reference count is called Least Frequently Used (LFU). Option C correctly names LFU. Option A describes LRU, which bases decisions on recency, not frequency, so it would not necessarily pick the smallest count. Option B is FIFO, which removes the oldest loaded page regardless of count. Option D, the Clock algorithm, approximates LRU using a use bit, not a count. LFU directly matches the definition, making C the correct choice.

Q2. Why does a counting-based replacement algorithm typically generate fewer page faults than a pure FIFO scheme?

A.It removes the most frequently used pages
B.It removes the least frequently used pages ✅
C.It removes the newest pages
D.It removes pages at random
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Counting-based algorithms keep a counter for each page and evict the one with the lowest count, i.e., the least frequently used page. This tends to keep pages that are accessed often, reducing the chance of a future fault. Option B states this behavior. Option A is opposite, removing heavily used pages, which would increase faults. Options C and D describe unrelated strategies, so they are incorrect.

Q3. A system tracks page reference counts over the last 1,000 accesses. Page X has count 5, Page Y count 20, and Page Z count 2. A new page must be loaded. Which page should be evicted under a counting-based algorithm?

A.Page X
B.Page Y
C.Page Z ✅
D.No eviction needed
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: Counting-based replacement chooses the page with the smallest reference count because it is the least frequently used. Among the three pages, Z has the lowest count (2), so it is the best candidate for eviction. Option C correctly identifies Page Z. Option A (Page X) and B (Page Y) have higher counts and would be kept longer. Option D is impossible because a new page requires a free frame, so eviction is mandatory.

Q4. Compared to LRU, what hardware overhead does a counting-based page-replacement algorithm primarily require?

A.A timer for each page
B.A simple counter per page ✅
C.No extra hardware
D.A stack of page identifiers
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: A counting-based scheme needs to maintain a numeric counter for each page to record how often it is accessed. This is a modest hardware addition: a small register per page. Option B captures this requirement. LRU typically needs timestamps or a stack to track order, which can be more complex than a single counter. Option A describes a timer, which is not necessary for simple counting. Options C and D describe either no overhead or a data structure unrelated to counting, making them incorrect.

Q5. Three pages A, B, and C reside in memory with reference counters A=7, B=3, and C=5. A fourth page D needs to be loaded. Which page will be replaced by the counting-based algorithm?

A.Page A
B.Page B ✅
C.Page C
D.No replacement needed
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The counting-based algorithm evicts the page with the lowest reference count because it is the least frequently used. Here, page B has the smallest count (3), so it will be selected for replacement. Option B correctly identifies page B. Pages A and C have higher counts (7 and 5) and are therefore more valuable to keep. Option D is impossible because a new page must occupy a frame, requiring eviction of an existing page.

Q6. How can a counting-based replacement algorithm cause cache pollution when a page receives many accesses in a short burst and then becomes idle?

A.Counters retain high values after the burst ✅
B.Counters are reset too frequently
C.It treats all accesses equally
D.It only tracks recency
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: When a page is accessed heavily in a brief period, its counter climbs to a high value. If the algorithm does not decay or reset counters, that high value persists even after the page becomes idle, preventing its eviction and causing other useful pages to be displaced—a phenomenon known as cache pollution. Option A describes this exact situation. Option B would actually mitigate pollution, not cause it. Option C is unrelated, and option D describes LRU, not counting‑based behavior.

Q7. In a system using 8‑bit saturating counters (max = 255) for page frequencies, many pages eventually reach the maximum value. Which strategy best restores discrimination among pages?

A.Periodically reset all counters ✅
B.Replace counters with larger bit‑width
C.Switch to a pure LRU policy
D.Ignore the counters entirely
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: When counters saturate at 255, they can no longer distinguish between frequently used pages, so all appear equally popular. Periodically resetting the counters restores their ability to differentiate recent usage patterns, making option A the most effective fix. Option B would also work but requires hardware changes; the question asks for the best immediate strategy. Options C and D abandon counting altogether, which defeats the purpose of a counting‑based scheme.

Q8. A web server caches 4 pages. Their hit counts after a day are: P1=120, P2=45, P3=78, P4=30. A new page P5 is requested. Which page will the counting-based replacement algorithm evict?

A.P1
B.P2
C.P3
D.P4 ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: The counting-based algorithm evicts the cached page with the lowest hit count because it is the least frequently accessed. Among the cached pages, P4 has the smallest count (30), making it the prime candidate for eviction to make room for P5. Option D correctly identifies P4. Options A, B, and C have higher counts and would be retained longer under the algorithm.

🔗 Related Topics (MCQs)