Hi
In the specification, there are several places where a total order is
stated to exist. It is not always clear to me whether that is intended to
be a requirement, or merely a side observation.
In the case of synchronization, the specification says
"There is a total order over all lock and unlock actions performed by an
execution of a
program".
Consider two threads, where each letter represents a lock and unlock action
on a named object's monitor.
Thread 1 Thread 2
A
A
X Y
B
B
Does a total order exist here? In particular, what is the order of the
locks on X and Y?
The two threads may be running on separate processors, which are separated
in space. If the lock operations occur sufficiently closely in time, then
there is no defined order for them.
It might seem that an order can be determined by looking at the operations
in main memory, but these are different memory locations and could involve
separate memory hardware, data bus, etc. Indeed, these locking operations
do not necessarily have to go as far as main memory anyway. The JVM may be
scheduling threads in a way such that X is not visible to any thread that
will run on processor 2, and Y is not visible to any thread running on
processor 1. In that case there is no need for the main memory to be
involved in these locks, and to talk about their order may be entirely
meaningless.
A real multiprocessor system that is necessarily spread out through space
can simulate the behaviour of a system that is located in one place, and
thereby provide a total order, but only at the cost of limiting its
performance.
Are the statements about total order in the specification really necessary?
Sylvia.
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:55 EDT