- 2079 Asoj · 5 marks
Cache write policy and replacement algorithm
Short answer
Write policies: write-through updates cache and memory together; write-back writes only to cache, marking the line dirty, and updates memory on eviction. Replacement algorithms select a victim when the set is full: random, FIFO, LRU (least recently used), LFU (least frequently used). A dirty block under write-back is first written back to memory.
Describe write policy and replacement algorithm used in cache memory.
Write policy
When the processor writes data that is in the cache, the cache and main memory must remain consistent.
- Write-through: write to cache and main memory together. Memory is always up to date and the design is simple, but every write takes memory time and increases bus traffic.
- Write-back: write only to cache and mark the line dirty. The block is written to memory when it is evicted. Faster and less traffic, but memory is temporarily inconsistent and control is more complex.
- On a write miss: write-allocate (fetch block into cache, then write) or no-write-allocate (write directly to memory).
Replacement algorithm
On a miss with the cache (set) full, a block must be removed to make room. Direct mapping has only one choice, but associative and set-associative caches need an algorithm:
- Random: simplest, selects any line.
- FIFO: removes the oldest-loaded block.
- LRU: removes the block unused for the longest time; usually best, as it uses temporal locality.
- LFU: removes the least frequently used block. If the victim is dirty (write-back), it is first written back to memory.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Cache replacement policies · Embedded System, chapter 4
- Cache memory mapping techniques · Embedded System, chapter 4 · asked 3×
- Which cache is better (4KB vs 12KB) · Embedded System, chapter 4 · asked 2×
- Which cache is better (2KB vs 8KB) · Embedded System, chapter 4 · asked 2×
- Need for replacement algorithm in cache · Computer Organization and Architecture, chapter 6
- Cache write policy techniques · Computer Organization and Architecture, chapter 6
- Memory characteristics and LRU replacement · Computer Organization and Architecture, chapter 6
- Direct mapping with 32-block memory, 8-block cache · Computer Organization and Architecture, chapter 6 · asked 3×