At 4:23 PM +0000 12/31/01, Roly Perera wrote:
>Could someone humour me and outline (or point me to) the theory behind
>this?
>
>What I'm unclear about is the meaning of the claim that example 1
>terminates "eventually". How long does one have to wait to be sure that
>the example isn't going to terminate, and therefore that the
>implementation executing the code is broken? It seems to me (naively,
>no doubt) that the assertion that example 1 terminates isn't testable in
>finite time.
>
>- Roly
>
>Roly Perera
>Ergnosis Ltd
The problem is that putting specific time bounds or other qualitative
numeric guarantees into a specification is too difficult. Whatever
values we give now might not be appropriate in 20 years. Also, what
if you want to implement a JVM as part of the Long Now project
(http://www.longnow.org/), which might execute only one bytecode/hour?
Saying that it must eventually terminates means that a compiler can't
transform example 2 from
Example 2:
Initially, x = 0 (x is non-volatile in this example).
Thread 1:
int r1;
do {
Thread.yield();
synchronized(this) {
r1 = x;
}
} while (r1 == 0);
Thread 2:
synchronized(this) {
x = 1
}
to
Illegal modification of Example 2:
Initially, x = 0 (x is non-volatile in this example).
Thread 1:
int r1;
synchronized (this) {
do {
Thread.yield();
r1 = x;
} while (r1 == 0);
}
Thread 2:
synchronized(this) {
x = 1
}
which is all we are trying to prevent.
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:36 EDT