reshown by
1,224 views
0 0 votes
In this question can someone plz explain to me the write back part? Why are we taking write back time only for cache misses? Why not for hits?  How to know when a block is going to be replaced and when to consider write back time.

1 Answer

1 1 vote

In a cache system, when a block is modified in the cache, it is marked as 'dirty' or 'modified', which indicates that the block needs to be written back to the main memory when it is replaced. Now, there are two ways to handle this write-back:

  1. Write-through: In this scheme, every time a cache line is modified, the corresponding main memory location is updated simultaneously. This ensures that the data in the main memory is always consistent with the data in the cache, but it leads to more write cycles to the main memory, which can be slower.

  2. Write-back: In this scheme, the updates are made only to the cache, and the main memory is updated only when the cache block is replaced. This can lead to a faster performance since multiple updates can be made to the cache block before the write-back, but it can also lead to the main memory and cache becoming inconsistent.

Coming to your question, the write-back time is considered only for cache misses because when there is a cache hit, the data is already in the cache and there is no need to write it back to the main memory. However, when there is a cache miss and a block is replaced, the cache controller needs to write the modified block back to the main memory before it can replace it with a new block. This is when the write-back time is considered.

The cache controller determines which block to replace based on a replacement policy, such as least recently used (LRU) or first-in first-out (FIFO). When a block is selected for replacement, if it is marked as 'dirty', then its contents must be written back to the main memory before the block is replaced.

To summarize, the write-back time is considered only for cache misses because that is when a cache block needs to be replaced and potentially written back to the main memory. When a block is replaced, the cache controller checks if it is marked as 'dirty' and writes it back before replacement.

 

Position:
Show:

Related questions

25 25 votes
3 answers 3 answers
21.9k
21.9k views
2 2 votes
0 0 answers
1.4k
1.4k views
Shubhanshu asked Aug 5, 2017
1,365 views
According to my calculation, the time required in write back is 240ns and for write through it should be 1920ns. Is it correct or not?
14 14 votes
1 answers 1 answer
10.1k
10.1k views
Mojo-Jojo asked Jan 11, 2016
10,068 views
A 64 word cache and main memory are divided into 16 word blocks. The main memory access time is 50 ns/word and the cache access time is 10 ns/word. Hit ratio for read ope...
1 1 vote
1 1 answer
1.8k
1.8k views
rahul sharma 5 asked May 20, 2017
1,812 views
For hierarchical access and write-through,The average write time is given by: 1. Twt=H×Tmemory+(1−H)×(Tcache+Tmemory)2. Twt=TmemoryWhich one to refer in question?Can we i...