1
\$\begingroup\$

I am studying write policies in cache memory ( for first time ). I am able to understand the 'write-through' but i am not able to understand 'write back' and the problems associated with it . Please can anyone explain me the 'write-back' concept clearly .

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

In a write-through cache every store operation from the processor simultaneously writes the new data into the cache-line and into the backing store (the next larger cache or the main memory).

In a write-back cache a store operation from the processor modifies only the cache-line, so the cache-line contains the most recent data while the data in the backing store is stale. The write to the backing store happens only when the cache line in question gets replaced because it is needed for some other line at a different address.

The pictures on the wikipedia page about caching are okay.

In a write-through cache every line is in only one of two states: valid or invalid. Thus when you need to fetch a line that is not in the cache you just throw out a line to make space for it

In a write-back cache every line can be in one of three states: valid, invalid, or dirty. When a read-miss occurs and you need to throw out a line to make space for the new line, the line you need to throw out may be dirty. If the line you need to throw out is dirty, you need to write it to the backing store before you can bring in the new line. This means that at the time you are processing a read-miss you may need to do two operations with the backing store instead of one.

If the same cache lines get written many times then write-back caches can dramatically reduce the number of times you need to send writes to the backing store. You just keep making modifications to the dirty cache line until the line needs to be replaced and then write back only the last values written to each location in the line.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ +1 You might also want to mention the "need" for ECC in a write-back cache (a write-through cache can use error detection and recover from the backing store); ECC is a bit less attractive with smaller writes ("requiring" stores to be RMWs). Write-through vs. write-back also has coherence issues (and probing requirements for DMA). \$\endgroup\$
    – user15426
    Jun 5, 2013 at 12:58
  • \$\begingroup\$ Also, write-back caches can be a big win when the backing store is not a purely random-access device (like, a hard-drive) because the cache makes it possible to re-order the writes to be more sequential, avoiding seek times. \$\endgroup\$
    – Phil Frost
    Jun 5, 2013 at 15:37
  • \$\begingroup\$ @Wandering Logic , thanx a lot man ! that really helped \$\endgroup\$
    – abkds
    Jun 6, 2013 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.