IAE Academy

GATE 2022 CS Q.24: solution and answer

GATE 2022 · CSQ.24 · 1 mark · MSQ

Let WB and WT be two set associative cache organizations that use LRU algorithm for cache block replacement. WB is a write back cache and WT is a write through cache. Which of the following statements is/are FALSE?

  1. (A)

    Each cache block in WB and WT has a dirty bit.

  2. (B)

    Every write hit in WB leads to a data transfer from cache to main memory.

  3. (C)

    Eviction of a block from WT will not lead to data transfer from cache to main memory.

  4. (D)

    A read miss in WB will never lead to eviction of a dirty block from WB.

See the question in the paper

Answer and solution

ANSWER

The FALSE statements are A, B and D.

Official answer: A, B, DSource: Official answer key, GATE 2022 CS (IIT Kharagpur)

  1. A cache needs a dirty bit only to track whether a block's cached copy differs from main memory. In a write-through (WT) cache, every write is immediately propagated to memory, so cache and memory are always identical -- WT never needs a dirty bit. A write-back (WB) cache does need one, since writes are deferred. Statement (A) claims both WB and WT have a dirty bit, which is false because WT does not need one.

  2. In a write-back (WB) cache, a write hit updates only the cache line and sets its dirty bit; the modified data is written to main memory later, typically only when that block is evicted. So a write hit does not, by itself, cause a transfer from cache to memory. Statement (B) is therefore false.

  3. In a write-through (WT) cache, main memory is kept current after every write. Consequently, when a block is evicted from WT, memory already has the latest data and no write-back transfer is required. Statement (C) is therefore true (not false).

  4. On a read miss in WB, the LRU-selected victim block may itself be dirty (modified since being cached); before it can be replaced, it must be written back to main memory. So a read miss can indeed cause eviction of a dirty block, contradicting the claim that it "will never" happen. Statement (D) is therefore false.

  5. Collecting the false statements: A, B, and D are false, while C is true.

KEY IDEA

In a write-back cache, only a dirty (modified) block needs an eventual write to memory, and that write happens only on eviction, not on every write hit. A write-through cache never needs a dirty bit because memory is updated immediately on every write, so its blocks are never "ahead of" memory.

WATCH OUT FOR

Assuming every cache, regardless of write policy, needs a dirty bit, or assuming a write hit in a write-back cache must immediately propagate to main memory the way a write-through cache does.

From the GATE 2022 CS paper. Every question of this paper · Download the full paper · All 22 Memory & cache questions, with notes

More Memory & cache questions