[concurrency-interest] Volatile stores in constructors, disallowed to see the default value

Valentin Kovalenko valentin.male.kovalenko at gmail.com
Wed Nov 27 12:06:25 EST 2013

Aleksey Shipilev wrote
>>Trace A: one that reads (r1=0):
>> read(a, !null)
>>    \--po--> vread(a.f, 0)
>>                   \---sw---> vstore(a.f, 42)
>>                                   \---po---> store(a)
Andreas Lochbihler wrote
>>In your reasoning, you do not distinguish between synchronization order
(so) and synchronizes-with order (sw)

I agree with Andreas: can't see why there is an sw(vread(a.f, 0), vstore(a.f,
42)) because as JSL states: "A write to a volatile variable v
synchronizes-with all subsequent reads of v by any thread (where
"subsequent" is defined according to the synchronization order)". And
according to Aleksey's trace vread(a.f, 0) is antecedent (not subsequent)
of vstore(a.f, 42) so there is no SW.

Doug Lea wrote
>>you cannot ever reorder volatile stores with any other stores

How is that can be true? Considering the following example:
store(nonVolatile1, 1);
vstore(a.f, 42);
store(nonVolatile2, 2);
I agree that store(nonVolatile1, 1) can't be reordered with vstore(a.f,
42), but store(nonVolatile2, 2) can be reordered with vstore(a.f, 42) and
this is exactly what we have in the original example: store(a) can be
reordered with vstore(a.f, 42). Where am I wrong?

Still I believe that "the only allowed value is {42}", however I can't
understand why it's correct...
Homo homini lupus est.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20131127/dadb9217/attachment.html>

More information about the Concurrency-interest mailing list