[concurrency-interest] Relativity of guarantees provided by volatile

Marko Topolnik mtopolnik at inge-mark.hr
Sat Aug 18 09:02:29 EDT 2012

Yuval, rereading the earlier posts I noticed this one from you:

> That said, 17.4.3 does imply that the reads will be viewable in a wall-clock-sequential way, albeit informally
>     Sequential consistency is a very strong guarantee that is made about visibility and ordering in an execution of a program. Within a sequentially consistent execution, there is a total order over all individual actions (such as reads and writes) which is consistent with the order of the program, and each individual action is atomic and is immediately visible to every thread.
> (emphasis on "is immediately visible")

The major point to note is that the JLS **does not** enforce sequential consistency! It even spells it out directly below your quote:

"If we were to use sequential consistency as our memory model, many of the compiler and processor optimizations that we have discussed would be illegal."

The whole model of happens-before revolves around making sequentially INCONSISTENT executions APPEAR to be consistent, as observed by all executing threads, thus allowing all the optimizations that are discussed on this mailing list.


More information about the Concurrency-interest mailing list