On Wed, Jan 28, 2004 at 12:53:09PM -0500, Melvin Smith wrote:
> At 12:27 PM 1/23/2004 -0800, Damien Neil wrote:
> >Java Collections are a standard Java library of common data structures
> >such as arrays and hashes.  Collections are not synchronized; access
> >involves no locks at all.  Multiple threads accessing the same
> >collection at the same time cannot, however, result in the virtual
> >machine crashing.  (They can result in data structure corruption,
> >but this corruption is limited to "surprising results" rather than
> >"VM crash".)
> 
> But this accomplishes nothing useful and still means the data structure
> is not re-entrant, nor is it corruption "resistant", regardless of how we 
> judge it.

Quite the contrary--it is most useful.

Parrot must, we all agree, under no circumstances crash due to
unsynchronized data access.  For it to do so would be, among other
things, a gross security hole when running untrusted code in a
restricted environment.

There is no need for any further guarantee about unsynchronized data
access, however.  If unsyncronized threads invariably cause an exception,
that's fine.  If they cause the threads involved to halt, that's fine
too.  If they cause what was once an integer variable to turn into a
string containing the definition of "mulching"...well, that too falls
under the heading of "undefined results".  Parrot cannot and should
not attempt to correct for bugs in user code, beyond limiting the extent
of the damage to the threads and data structures involved.

Java, when released, took the path that Parrot appears to be about
to take--access to complex data structures (such as Vector) was
always synchronized.  This turned out to be a mistake--sufficiently
so that Java programmers would often implement their own custom,
unsynchronized replacements for the core classes.  As a result,
when the Collections library (which replaces those original data
structures) was released, the classes in it were left unsynchronized.

In Java's case, the problem was at the library level, not the VM
level; as such, it was relatively easy to fix at a later date.
Parrot's VM-level data structure locking will be less easy to change.

                     - Damien

Reply via email to