RE: JavaMemoryModel: init methods

From: Boehm, Hans (hans_boehm@hp.com)
Date: Mon Oct 02 2000 - 20:45:30 EDT


> From: Jeffrey G. Bogda [mailto:bogda@cs.ucsb.edu]
> It sounds to me like you are saying that properly
> synchronized programs are
> possible, but people aren't going to write them. I agree with
> you, but I think
> it is unfortunate. I would rather see programmers and library
> writers fully
> synchronize their shared data and let the compiler and
> run-time system worry
> about "cheating" in order to improve performance. I guess the
> only way that is
> going to happen is if they fully trust the compiler and
> run-time system or if
> the language somehow requires proper synchronization.
I agree that that would be nice. But it seems completely hopeless to me.
Some of the unsynchronized algorithms that come to mind (e.g. caches with
atomic pointer updates, some iterative numerical algorithms) have the
property that the exectuted instruction stream is different depending on the
outcome of the races; it requires profound reasoning to convince yourself
that either outcome is acceptable. (E.g. whether you hit the cache or not
doesn't affect the result; whether you use the old or new values in
Gauss-Seidel iteration doesn't affect the limit of the computed sequence,
though it does affect intermediate values.)
> ...
>
> > I think we agree. But it seems to me that this is almost
> exactly what you
> > need to do to remove the synchronization in the beans
> example? You need to
> > recognize that field values are constant once the object
> becomes public, and
> > then remove the synchronization on the bean from field
> accesses, eventhough
> > the bean is accessible from multiple threads? Or did I
> misunderstand?
>
> In some situations I think it should be possible to detect
> this. It seems like
> you have a particular scenario in mind. Can you give some sample code?
>
Unfortunately, I have no experience with Java Beans, which is one reason I
appreciate this discussion. It still seems to me that this is at least as
hard as removing synchronizations on globals around empty blocks, since at
best you can prove that synchronizing around a field access amounts to
synchronizing around an empty block?

Hans
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



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