• retagged by
18,961 views
53 53 votes

​​​​​​Assume a two-level inclusive cache hierarchy, $L1$ and $L2$, where $L2$ is the larger of the two. Consider the following statements.

  • $S_1$: Read misses in a write through $L1$ cache do not result in writebacks of dirty lines to the $L2$
  • $S_2$: Write allocate policy must be used in conjunction with write through caches and no-write allocate policy is used with writeback caches.

Which of the following statements is correct?

  1. $S_1$ is true and $S_2$ is false
  2. $S_1$ is false and $S_2$ is true
  3. $S_1$ is true and $S_2$ is true
  4. $S_1$ is false and $S_2$ is false

3 Answers

Best answer
52 52 votes

$S_1:$ Read Miss in a write through $L1$ cache results in read allocate. No write back is done here, as in a write through $L1$ cache, both $L1$ and $L2$ caches are updated during a write operation (no dirty blocks and hence no dirty bits as in a write back cache). So during a Read miss it will simply bring in the missed block from $L2$ to $L1$ which may replace one block in $L1$ (this replaced block in $L1$ is already updated in $L2$ and so needs no write back). So, $S_1$ is TRUE.

$S_2:$ This statement is FALSE. Both write-through and write-back policies can use either of these write-miss policies, but usually they are paired in this way.

  • No write allocation during write through as $L1$ and $L2$ are accessed for each write operation (subsequent writes to same location gives no advantage even if the location is in $L1$ cache).
  • In write back we can to do write allocate in $L1$ after a write operation hoping for subsequent writes to the same location which will then hit in $L1$ and thus avoiding a more expensive $L2$ access.

Correct Answer: A.

Cache Writing Policies

• selected by
8 8 votes

1) Core concepts (root)

Write-through vs write-back

  • Write-through: every store updates the level-1 cache and is immediately forwarded to the next level (L2/main memory). Because writes propagate on every store, L1 lines do not become “dirty” (there’s no need for a dirty bit in L1 for the written word), so an evicted L1 line does not normally need to be written back to L2 — L2 already has the up-to-date value. 

  • Write-back: stores update only the L1 cache line and mark it dirty. The updated data is written to L2 only when the dirty line is evicted from L1. Thus L1 can cause writebacks to L2 on eviction. 

Read-miss behavior in an inclusive two-level hierarchy

  • On an L1 read miss, the block is fetched from L2 into L1 (read-allocate) if the policy fetches on read miss. Whether this causes any writeback from L1→L2 depends on whether the L1 line being replaced was dirty (i.e., modified in L1 but not yet pushed to L2). In a write-through L1 the replaced line will not be dirty (since all writes were forwarded), so no L1→L2 writeback is needed when bringing the miss block in. 

Write-allocate vs no-write-allocate (on write miss)

  • Write-allocate (fetch-on-write): on a write miss the cache allocates (loads) the block into the cache and then performs the write there.

  • No-write-allocate (write-no-allocate / write-around): on a write miss the cache does not allocate; the write is sent directly to the next level (L2 / memory) without bringing the block into L1.

  • These write-miss policies are independent mechanisms from the choice of write-through/write-back; architects often pair write-through with no-write-allocate and write-back with write-allocate as common choices, but they are not logically forced to each other. The word “must” in S2S_2S2​ makes the statement too strong. 


2) Apply to the statements

S1​: “Read misses in a write-through L1 cache do not result in writebacks of dirty lines to the L2.”

  • Because a write-through L1 forwards writes to L2 immediately, L1 lines are not held dirty — so when you bring a new block into L1 on a read miss and must evict some L1 line, that evicted line does not require a writeback to L2.

  • Therefore S1S_1S1​ is true. 

S2​: “Write allocate policy must be used in conjunction with write-through caches and no-write-allocate policy is used with writeback caches.”

  • Common practice pairs (write-through → no-write-allocate) and (write-back → write-allocate), but these are design choices, not hard requirements. Both write-through and write-back caches can be configured with either write-allocate or no-write-allocate depending on workload and design trade-offs. Because S2S_2S2​ uses the word “must”, it is false. (If it had said “is usually paired with” it would be acceptable; but as a categorical “must” it is incorrect.)

4 4 votes
Ans should be A.)
S1:- Read Miss results in read allocate and no writing is done here as in write through simultaneously l1 cache and l2 cache are updated during the write miss. So in Read miss it will simply go to l2 cache and bring the respected block from l2 cache to l1. Also no dirty bit is used in case of Write through.

S2:- No write allocation during write through as l1 and l2 are accessed simultaneously and in write back we need to do write allocate after updating the old block in l2 cache if dirty bit is 1 otherwise it will simply do write allocate to l1 cache.
Answer:
Position:
Show:

Related questions

42 42 votes
7 answers 7 answers
17.0k
17.0k views
Arjun asked Feb 18, 2021
16,983 views
Consider a set-associative cache of size $\text{2KB (1KB} =2^{10}$ bytes$\text{)}$ with cache block size of $64$ bytes. Assume that the cache is byte-addressable and a $3...
83 83 votes
13 answers 13 answers
39.9k
39.9k views
Arjun asked Feb 18, 2021
39,939 views
Consider a pipelined processor with $5$ stages, $\text{Instruction Fetch} (\textsf{IF})$, $\text{Instruction Decode} \textsf{(ID)}$, $\text{Execute } \textsf{(EX)}$, $\te...
57 57 votes
5 answers 5 answers
23.9k
23.9k views
Arjun asked Feb 18, 2021
23,944 views
Consider a computer system with $\text{DMA}$ support. The $\text{DMA}$ module is transferring one $8$-bit character in one $\text{CPU}$ cycle from a device to memory thro...
17 17 votes
5 answers 5 answers
5.9k
5.9k views
Arjun asked Feb 18, 2021
5,905 views
Listening to music during exercise improves performance and reduces discomfort. Scientists researched whether listening to music while studying can help students learn be...