retagged by
593 views
5 votes
5 votes

Cache memory with a line size of $\large\color{maroon}{\text{32}}$B. In a cache miss situation block of words are loaded from Main memory to cache and then accessed from the cache.

  • $A$. Main memory has only word transfer capability and $\large\color{maroon}{\text{1}}$ word ($32$ bit) transfer requires $\large\color{maroon}{\text{30}}$ns.
  • $B$. Main memory has block transfer capability and $1$st word access time = $30$ns and $5$ns for each word after that.  

In each of the above cases ($A$ and $B$) how many writes a $\color{maroon}{\text{cache line}}$ should get on average before being replaced such that write back policy becomes more effective than write-through?  

retagged by

1 Answer

Best answer
4 votes
4 votes

Cache memory with a line size of 32 B.

A. Main memory has only word transfer capability and 1 word (32 bit) transfer requires 30ns.

For this case, we need to see when write back is more efficient than write through, i.e, Write back takes less time than Write through.

A block is having 8 words with each word = 4 B

Write Back Cache : Cache implementing this policy contains data which is only updated in the cache and updated word is never written back till a block is replaced in the cache memory.

So, if all the 8 words in a cache line are updated, all updates only persist in the cache and not in MM, till a block is replaced in the cache memory.

Total time to update WB cache = 30 * 8 = 240 ns and MM will also take the same time to be updated

Write Through Cache : If instead we used WT cache, then all updates to a single word are simultaneouly needed to be written to the cache memory and so whatever happens MM will always be updated.

So, for 8 updates to all the words = each will take 30 ns to get updated in the cache and hence in the MM, but If a single extra update comes for a word inside the cache, then 30 ns time more will be taken to update the cache and memory.

In that case, assuming before the cache block is swapped out to MM, WB is more efficient as after 240 ms it will be swapped but in the worst case, in case of WT it will take more than 8 times .

B. Main memory has block transfer capability and 1st word access time = 30ns and 5ns for each word after that

Same approach for WB cache = 30 + 7 * 5 = 65 ns and in case of WT each word will be updated to memory simultaneously and all updates will take 30 ns . In this case, WB is far much better before swap out .

selected by

No related questions found