reshown by
761 views
0 votes
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.
reshown by

1 Answer

1 votes
1 votes

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.

 

Related questions

2 votes
2 votes
0 answers
2
Shubhanshu asked Aug 5, 2017
773 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?
1 votes
1 votes
1 answer
4