diff --git a/doc/synchronization-notes.md b/doc/synchronization-notes.md index dfdeaa3f3..14d857076 100644 --- a/doc/synchronization-notes.md +++ b/doc/synchronization-notes.md @@ -52,3 +52,13 @@ class Node # ... end ``` +## Piggybacking + +Any write executed before volatile write based on program-order is visible to +the volatile read as well, which allows +[piggybacking](http://stackoverflow.com/questions/8769570/volatile-piggyback-is-this-enough-for-visiblity). +Because it creates synchronizes-with (JMM term) order between volatile write +and read, which participates in creating happens-before order. + +This trick is used in some of the abstractions, to avoid unnecessary +synchronization or volatile declarations. diff --git a/doc/synchronization.md b/doc/synchronization.md index 94787d74b..86fad6211 100644 --- a/doc/synchronization.md +++ b/doc/synchronization.md @@ -34,7 +34,7 @@ time-consuming and error-prone. The Ruby memory model is a framework allowing to reason about programs in concurrent and parallel environment. It defines what variable writes can be observed by a particular variable read, which is essential to be able to -determine if a program is correct. It is achieved be defining what subset of +determine if a program is correct. It is achieved by defining what subset of all possible program execution orders is allowed. A memory model sources: @@ -70,14 +70,9 @@ C++11). This is not a formal model. Key properties are: -- **volatility (V)** - Any written value is immediately visible to any - subsequent volatile read of the same variable. Any write executed before - volatile write based on program-order is visible to the read as well, which - allows - [piggybacking](http://stackoverflow.com/questions/8769570/volatile-piggyback-is-this-enough-for-visiblity). - (Same meaning as in Java, it creates synchronizes-with (JMM term) order - between write and read, which participates in creating happens-before - order.) +- **volatility (V)** - A written value is immediately visible to any + subsequent volatile read of the same variable on any Thread. (It has same + meaning as in Java.) - **atomicity (A)** - Operation is either done or not as a whole. - **serialized (S)** - Operations are serialized in some order (they cannot disappear). This is a new property not mentioned in other memory