IAE Academy

GATE 2024 CS1 Q.53: solution and answer

GATE 2024 · CS1Q.53 · 2 marks · MSQ

Consider two set-associative cache memory architectures: WBC, which uses the write back policy, and WTC, which uses the write through policy. Both of them use the LRU (Least Recently Used) block replacement policy. The cache memory is connected to the main memory. Which of the following statements is/are TRUE?

  1. (A)

    A read miss in WBC never evicts a dirty block

  2. (B)

    A read miss in WTC never triggers a write back operation of a cache block to main memory

  3. (C)

    A write hit in WBC can modify the value of the dirty bit of a cache block

  4. (D)

    A write miss in WTC always writes the victim cache block to main memory before loading the missed block into the cache

See the question in the paper

Answer and solution

ANSWER

The TRUE statements are (B) and (C).

Official answer: B, CSource: Official answer key, GATE 2024 CS1 (IISc Bengaluru)

  1. A read miss in WBC (write-back cache): LRU replacement picks the victim purely by recency, with no exemption for dirty blocks, so a dirty block CAN be evicted (triggering a write-back first). Statement (A) ("never evicts a dirty block") is FALSE.

  2. A read miss in WTC (write-through cache): every write is immediately propagated to main memory, so no cache block in WTC is ever dirty. Evicting any block on a read miss therefore never requires a write-back to memory. Statement (B) is TRUE.

  3. A write hit in WBC: the write updates the cached copy only (not memory), so the block's dirty bit is set to 1 to record that it now differs from memory and must be written back later. This is a modification of the dirty bit's value. Statement (C) is TRUE.

  4. A write miss in WTC: since (as in step 2) no WTC block is ever dirty, the victim block being replaced already matches main memory, so it does NOT need to be written to memory before the new block is loaded. Statement (D) ("always writes the victim... before loading") is FALSE.

  5. Hence the TRUE statements are (B) and (C).

KEY IDEA

In a write-back cache, memory is updated only when a dirty (modified) block is evicted, so the cache's dirty bit tracks which blocks are out of sync with memory; in a write-through cache every write goes to memory immediately, so no cache block is ever dirty and eviction never needs a write-back.

WATCH OUT FOR

Assuming LRU somehow "protects" dirty blocks from being chosen as the eviction victim on a read miss (it does not — LRU picks purely by recency, so a dirty block can absolutely be evicted, triggering a write-back first), and conversely forgetting that in write-through caches no block is ever dirty, so eviction is a silent, cost-free operation with respect to memory.

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

More Memory & cache questions