I was just wondering about in write allocation policy of caches, first we access data from main memory and put into cache and then update in the cache. If anyway we use write back policy to counter cache coherency then after updating data into cache we don't have to update simultaneously in the main memory. But I am not able to understand why are we fetching old data from memory to cache first and then updating in case of write miss and we use write allocation with write back policy, why not directly put that data into cache itself.
Asked
Active
Viewed 26 times
0
-
If you don't have the original data, you won't know which bytes are dirty or not when you need to eventually evict and write back to main memory, if you don't eventually write all the bytes of the cache-line before that happens. See the linked duplicate. Also in a system with multiple CPUs, for maintaining coherency by getting exclusive ownership. – Peter Cordes May 07 '22 at 09:05