On 5/7/13 3:44 PM, Andrei Alexandrescu wrote:
On 5/7/13 5:57 PM, Mehrdad wrote:
On Tuesday, 7 May 2013 at 19:49:30 UTC, Andrei Alexandrescu wrote:
A memory barrier is not a one-way thing, i.e. not only the writer must
do it. Any operation on shared memory is a handshake between the
writer and the reader. If the reader doesn't do its bit, it can see
the writes out of order no matter what the writer does.

Andrei



Andrew, I still don't understand:

The writer is ensuring that writes to memory are happening _after_ the
object is initialized and _before_ the reference to the old object is
modified, via a memory barrier.

The writer is only half of the equation. The reader has its own cache to
worry about and its own loading order.

Unless you're claiming that a memory barrier _doesn't_ do what it's
supposed to (i.e., the memory module is executing writes out-of-order
even though the processor is issuing them in the correct order), there
is no way for _anyone_ to see a partially initialized object anywhere...

I'm not claiming, I'm destroying :o). There is. I know it's confusing.
You may want to peruse the reading materials linked by others.


Andrei

(this might be a repeat, I've only skimmed this thread)

Section 8.2 of this doc is a good read:
  http://download.intel.com/products/processor/manual/325384.pdf

There's a couple allowed re-orderings that are not what most people expect.

Later,
Brad

Reply via email to