[concurrency-interest] Volatile array and Wait
jmanson at cs.purdue.edu
Wed Oct 19 12:46:49 EDT 2005
Chris Purcell wrote:
>> b = x;
>> b = b;
> Umm, shouldn't that be
> b = b;
> b = 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 = 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