[concurrency-interest] Relativity of guarantees provided by volatile

Zhong Yu zhong.j.yu at gmail.com
Fri Aug 17 21:33:35 EDT 2012


Consider this physical model:

Each thread is a person Tx.

There's a person V managing all variables.

To make a write, Tx sends a paper mail to V. No return mail is
required, therefore a write is very short.

To make a read, Tx sends a paper mail to V, and waits for return mail.

The synchronization order is the order the mails received by V.

This seems to be a valid JMM model.

--

Now suppose thread R is very close to V, therefor reads are also very
short. (it's easier to talk about temporal order between short
actions) Suppose thread W is very far away from V.

To realize OP's example, consider the numbers are in hours, and route
W -> V takes 48 hours.

On Monday, W writes v=1, it reaches V on Wednesday. On Tuesday R reads
v=0. So the write is after read in sync order, yet write is before
read in temporal order(even considering relativity - all persons are
on Earth)

Therefore sync order doesn't have to be consistent with temporal order.


More information about the Concurrency-interest mailing list