in CO and Architecture retagged by
8,027 views
18 votes
18 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
in CO and Architecture retagged by
by
8.0k views

4 Comments

In Layman's Term:

Write Through cache can simultaneously write in the levels (top and next levels). So, there is no need of write back. It can use both write allocate and without write allocate policy.

So, S2 is definitely False...due to the word "must" for Write Through and also Write Back cache can use with write allocate policy...There are many such examples and electronics company that use Write Back with Write allocate policy.

Write Back is corresponding to a dirty bit which is equivalent as Thrashing, Page Fault Service concept in OS. These topics are interrelated one is with Virtual Memory and the other for Physical Memory.

1
1
edited by
2
2

The following is primarily for S2 :-

In case of a write-through cache, data is simultaneously copied to higher level caches, backing storage or memory.

In case of a write-back cache, data is updated in the cache only, data updation in the memory is done at a later time.

In case of Write Allocation policy, data is loaded from the memory into the cache and then updated.

In case of No-Write / Write-Around Allocation policy, data is directly written to / updated in the main memory, without disturbing the cache.

Now, write-allocation policy is generally not used with a write-through cache since it becomes unnecessary to bring data from the memory to the cache and then updating the data in both cache (property of write-allocation policy) and main memory (property of write-through cache).

When no-write-allocation policy is used with a write-back cache, then data updation in memory is being done twice (1st updation is for no-write-allocation policy and the 2nd updation is for write-back policy), which again doesn’t give much of an advantage.

Write-allocation policy in conjunction with a write-back cache is more preferable.

6
6

2 Answers

17 votes
17 votes
Best answer

$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
by

4 Comments

Can you please provide any other resource to understand write allocate and no write allocate policies?

0
0

@KineticKarm , 

Here you can see. But I have a doubt in this given link it is mentioned that write allocate can be used with both the write through as well as write back , so why is option B wrong? @Arjun Sir !
0
0
because the word “must” is used. S2 would be true if “may” or “can” was used in place of “must”
1
1
edited by

@Sachin Mittal 1 @GO Classes sir, here I don’t understand how can we say for sure that read miss on L1 will never initiate write back in L2? 
Scenario:

We write to a block which is not in L1 but in L2, this block will have the dirty bit set. now, read from a block which is not in L1 or L2, assume that maps to same block as the block we wrote to earlier, this is initiate write back in L2.. What am I missing?

 I missinterpreted the question S1 is talking about L1 to L2 writebacks and not L2 to memory writebacks

1
1
2 votes
2 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:

Related questions