Re: JavaMemoryModel: allowed semantics question

From: Eliot Moss (moss@cs.umass.edu)
Date: Thu Mar 18 2004 - 06:49:18 EST


>>>>> "Bill" == Bill Pugh <pugh@cs.umd.edu> writes:

    Bill> I'd be more confident answering a test case. So let me propose one:

    Bill> Initially, x = 0

    Bill> Thread 1:
    Bill> x = 1

    Bill> Thread 2:
    Bill> x = 2

    Bill> Thread 3:
    Bill> r1 = x
    Bill> r2 = x
    Bill> r3 = x
    Bill> r4 = x

    Bill> Behavior in question: r1 = 0, r2 = 1, r3 = 2, r4 = 1

    Bill> Decision: Yes, this behavior is absolutely legal, even if you throw a
    Bill> pile a volatile accesses, dependences
    Bill> and synchronizations into thread 3 to try to keep the reads of x from
    Bill> being reorders (so long as thread 3 doesn't synchronize with threads 1
    Bill> and 2). In fact, thread 3 can also still see the value 0 for x, and x
    Bill> never has to stablize (unless, for example, thread 3 writes to x).

Cool! Thanks, guys!
(I thought it was all ok, but it's good to have your confirmation.)

-- Eliot
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:01:00 EDT