[concurrency-interest] Atomic assignment

Christian Vest Hansen karmazilla at gmail.com
Fri May 8 14:37:36 EDT 2009


On Fri, May 8, 2009 at 5:02 PM, Gregg Wonderly <gregg at cytetech.com> wrote:
> Okay, it we actually just have the ++/-- not atomic issue, than I am okay
> with that because I don't suddenly have new, broken code.  I looked around
> some more and ran the test code on that old issue on my dual core laptop and
> saw no failures.  But, I'm not sure after looking at that code whether it
> actually makes modifications in a way that would show a problem.

Were you running it on 64 bit hardware? It may be possible that while
the JLS and the JVM makes no effort to keep the long & double
operations atomic, your hardware may be providing its own guarantees
that are stricter.

Everything I have read on volatile under the Java 5 JMM until I read
that bug report, have either stated clearly or assumed that there was
no atomicity guarantees in volatile - only visibility guarantees.
Volatile is atomic for references and primitives of 32 or fewer bits
only by virtue of these values having a general atomicity guarantee,
that has nothing to do with volatile itself.

I believe that JCiP and numerous articles on the internet, are pretty
clear on this. (Not having read the JLS or JMM myself.)

>
> Gregg Wonderly
>
> Sam Berlin wrote:
>>
>> My interpretation is that the scenario today is that a volatile
>> long/double is atomic.  A non-volatile long/double is not atomic.  And the
>> RFE that was closed as will-not-fix was asking for all access to long/double
>> (even non-volatile) to be atomic.
>>
>> Sam
>>
>> On Fri, May 8, 2009 at 10:27 AM, Gregg Wonderly <gregg at cytetech.com
>> <mailto:gregg at cytetech.com>> wrote:
>>
>>    So will the compiler be changed to not allow volatile to exist on
>>    double/long declarations since it does not work?  Or might there be
>>    a warning that volatile does not produce atomic results on all
>>    statements that assign to or reference a double/long value?
>>
>>    Sigh...
>>
>>    Gregg Wonderly
>>
>>
>>    David Holmes wrote:
>>
>>        Hi Mark,
>>
>>        That bug is (or became) a RFE for the spec to make all accesses to
>>        double/long atomic and that is not going to happen hence the
>>        "will not fix".
>>        There are a number of other bugs that pertain to atomic access
>>        to volatile
>>        long/double eg: 4247780 which was fixed back in 1.2.2
>>
>>        Thanks
>>        David Holmes
>>
>>            -----Original Message-----
>>            From: concurrency-interest-bounces at cs.oswego.edu
>>            <mailto:concurrency-interest-bounces at cs.oswego.edu>
>>            [mailto:concurrency-interest-bounces at cs.oswego.edu
>>            <mailto:concurrency-interest-bounces at cs.oswego.edu>]On
>>            Behalf Of Mark
>>            Thornton
>>            Sent: Friday, 8 May 2009 7:29 AM
>>            To: concurrency-interest at cs.oswego.edu
>>            <mailto:concurrency-interest at cs.oswego.edu>
>>            Subject: [concurrency-interest] Atomic assignment
>>
>>
>>
>>            I was sure that the problem of (non)atomic assignment to
>>            volatile longs
>>            and doubles had been fixed, but this bug report suggests
>>            otherwise:
>>
>>            http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4023233
>>
>>            Anyone know for sure?
>>
>>            Mark Thornton
>>
>>            _______________________________________________
>>            Concurrency-interest mailing list
>>            Concurrency-interest at cs.oswego.edu
>>            <mailto:Concurrency-interest at cs.oswego.edu>
>>            http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>>
>>
>>
>>        _______________________________________________
>>        Concurrency-interest mailing list
>>        Concurrency-interest at cs.oswego.edu
>>        <mailto:Concurrency-interest at cs.oswego.edu>
>>        http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>>
>>
>>
>>    _______________________________________________
>>    Concurrency-interest mailing list
>>    Concurrency-interest at cs.oswego.edu
>>    <mailto:Concurrency-interest at cs.oswego.edu>
>>    http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>>
>>
>
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>



-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.



More information about the Concurrency-interest mailing list