Re: JavaMemoryModel: Idiom for safe, unsynchronized reads

From: Bill Pugh (
Date: Mon Jun 28 1999 - 14:33:48 EDT

>Hi Raymie,
>I'd like to understand more about the type of reordering operations you're
>describing, and I assume I'm probably not the only one on the list who'd be
>interested. Can you reference any online documentation or articles which
>describe how this works? Or, alternatively, supply a more detailed
>It's very counter-intuitive for me to hear about a processor that
>can apparently
>reorder operations to load data referenced off a pointer before it loads the
>pointer, if I understand your remarks properly.
> - Dennis

There are a couple of different formalisms for talking about memory
models, as well as different ways of implementing them.

One way to describe a memory model is to say that within a
processor/thread, actions can be reordered according to some set of
rules, and then the overall behavior must be as those the reordered
actions were executed according to some global interleaving.

But that is just a model. In reality, things don't happen atomically
with regards to some global order. You have things like processors
reading stale cache lines, reading old data that has been overwritten
by another processor. It turns out that these more complicated
situations can often be modelled by simpler, formal models.

So here is what might really happen:

                                Processor 2 has cached the contents of
                                address 0x1234

Processor 1 allocates a new
object at address 0x1234

Processor 1 initializes the
object at address 0x1234

Processor 1 does a memory

Processor 1 stores 0x1234
into address 0x5678

                                Processor 2 reads address 0x5678, gets

                                Processor 2 reads contents of object at address
                                0x1234 out of stale cache line

This behavior can be modeled by allowing the read of address 0x1234
to occur before the read of address 0x5678, even though the address
0x1234 is dependent on the value returned by reading address 0x5678.

        Bill Pugh

This is the JavaMemoryModel mailing list, managed by Majordomo 1.94.4.

To send a message to the list, email
To send a request to the list, email and put
your request in the body of the message (use the request "help" for help).
For more information, visit

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