[concurrency-interest] volatile guarantee for directbuffer
hans.boehm at hp.com
Tue Feb 14 17:17:35 EST 2012
> From: Nathan Reynolds
> Yes, all stores preceeding a volatile store will be visible. It doesn't matter if this store
> is on Java heap, off Java heap or else where. On x86, the JVM puts in a fence after the
> volatile store. This fence applies to all memory accesses regardless of where they are located.
This sounds entirely correct, except that the fence after a volatile store doesn't help in this
case. It's there only to order the volatile store with respect to a possible subsequent volatile load.
An x86 store by itself ensures that prior (in thread order) memory operations become visible
before the store, and that's the important point here.
This argument assumes that directBuffer is mapped write-back cacheable like the rest of the heap.
If the implementation plays with e.g. write-coalescing mappings, or uses non-temporal stores
without fences, then all bets are off. I sincerely doubt that, but haven't looked at the implementation.
More information about the Concurrency-interest