Skip to content

Commit

Permalink
Simplify volatile definition
Browse files Browse the repository at this point in the history
  • Loading branch information
pitr-ch committed Sep 28, 2015
1 parent d018594 commit 2b6a7bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
10 changes: 10 additions & 0 deletions doc/synchronization-notes.md
Expand Up @@ -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.
13 changes: 4 additions & 9 deletions doc/synchronization.md
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

1 comment on commit 2b6a7bd

@eregon
Copy link
Collaborator

@eregon eregon commented on 2b6a7bd Sep 28, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Please sign in to comment.