Prerequisite – Write Through and Write Back in Cache
During a read operation, when the CPU determines a word in the cache, the main memory is not included in the transfer. Thus, there are two ways that the system can proceed when the operation is a write.
1. Write Through Method : The simplest method is to update the main memory with every memory write operation, when the cache memory is update in parallel when it contains the word at the specified address. This can be known as the write through method.
2. Write Back Method :
During write operation, only the cache location is updated in the write back method. Then, the location is marked by a flag so that it is later copied to the main memory when the word is removed from the cache. For the write back method, the reason is that during the time a word remains in the cache, it can be updated multiple times. Thus, as long as the word remains in the cache, it does not matter if the copy in the main cache. This is only when the word is displaced from the cache which needs an exact copy that is rewritten into main memory.
Differentiate Between Write Through and Write Back Methods :
|S.No.||Write Through Method||Write Back Method|
|1||In this method main memory is updated with every memory write operation as well as cache memory is updated in parallel if it contains the word at the specified address.||In this method only cache location is updated during write operation.|
|2||Main memory always contains same data as cache.||Main memory and cache memory may have different data.|
|3||Number of memory write operation in a typical program is more.||Numeber of memory write operation in a typical program is less|
|4||When I/O device communicated through DMA would receive most recent data.||When I/O device communicated through DMA would not receive most recent data.|
|5||It is a process of writing cache and main memory simultaneously.||It is a process of writing cache and data is removed from cache, first copied to main memory.|
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.