Question

I'm reading about cache write policies, and I just want to know if I'm understanding this correctly.

When a read results in a cache miss, it'll get that block of memory and put it in the cache. A cache write miss then would mean that the location in memory that the program wants to write into is not within the cache, correct? So I'm reading the description of write-back, which is as follows according to wikipedia:

initially, writing is done only to the cache. The write to the backing store is postponed until the cache blocks containing the data are about to be modified/replaced by new content.

So the only time that the memory of a cache block can be replaced is during a read, correct? And a write would simply change the data in a particular location of memory (and this would be within a cache block if it is a hit), but it would leave the actual memory locations within the block the same, correct?

This is my understanding of it and I just want to make sure it's correct.

Edit: wait, I guess during a cache miss it will also be replacing/updating the cache blocks....

Was it helpful?

Solution

Wikipedia explains it quite well, actually. On one hand write-back vs. write-through defines when the data is written to the backing store (aka main memory):

  • Write-through – write is done synchronously both to the cache and to the backing store.
  • Write-back (or write-behind) – initially, writing is done only to the cache. The write to the backing store is postponed until the cache blocks containing the data are about to be modified/replaced by new content.

On the other hand write allocate vs. no-write-allocate defines how to deal with write misses, i.e. wether or not data from the backing store is brought into the cache:

  • Write allocate (aka fetch on write) – datum at the missed-write location is loaded to cache, followed by a write-hit operation. In this approach, write misses are similar to read misses.
  • No-write allocate (aka write-no-allocate or write around) – datum at the missed-write location is not loaded to cache, and is written directly to the backing store. In this approach, only system reads are being cached.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top