[concurrency-interest] Volatile array and Wait

Jeremy Manson jmanson at cs.purdue.edu
Wed Oct 19 12:46:49 EDT 2005

Chris Purcell wrote:

>> Write:
>> b[22] = x;
>> b = b;
> Umm, shouldn't that be
> b = b;
> b[22] = x;
> ?
> After all, there's not use in publishing preceding writes *after* the 
> lock's already released.

Nope.  The rule of thumb is that the release has to happen after you 
perform the writes you want to publish.  The acquire has to happen 
before you read the writes that have been published.

In this case, the write "b = b" is the release, and so must occur after 
the write "b[22] = x", which is the write we wish to publish.

Also, bear in mind that there is no lock in this case.  This is part of 
what makes it extremely difficult to analyze, and why people should 
probably avoid it where possible.


More information about the Concurrency-interest mailing list