[concurrency-interest] volatile guarantee for directbuffer

Boehm, Hans hans.boehm at hp.com
Tue Feb 14 14:46:48 EST 2012

> From: Holger Peine
> (I use to tell my students "writing to a volatile flushes the cache".)

That somewhat conveys the right idea, but not entirely.  In particular:

- If only v is volatile, then x = 1; v = 1; z = 1 does not ensure that the write to x becomes visible before the write to z.  Furthermore if v is known not to be read by another thread, the write to v can be turned into a non-volatile write.

- The cost model is wrong.  Writing to a volatile is typically many orders of magnitude cheaper than what it would take to write the entire cache at full memory bandwidth.  It's typically at most a store buffer that's really flushed.

I'd instead go with something like "So long as accesses to the same non-volatile variable can't happen at the same time, or are all reads, you get sequential consistency."


More information about the Concurrency-interest mailing list