RE: JavaMemoryModel: Reconsidering spurious wakeups

From: Boehm, Hans (
Date: Wed Nov 26 2003 - 19:27:38 EST

I agree with Martin's comments.

I'm also still investigating with people working on HP's JVMs.

My feeling is that the priorities should be:

1) A clean programming model. I'm not sure I've followed the discussion 100%,
but it looks to me like all proposals qualify, with the differences arising in
relatively rare cases. Neither model is conceptually simpler to me, though you
may be able to write more compact code without spurious wakeups in relatively rare cases.

2) Backwards compatibility with existing code. I'm not sure how many VMs do what
at the moment. I know that some VMs already try to filter out spurious wakeups. I don't
know whether that's near universal, or how correct those attempts are. But that seems
important to this argument, since we don't want to eliminate a guarantee that could be
safely relied on.

3) Compatibility with the underlying threads implementation.
I think that's important for the reason Martin mentioned:
JVMs are usually built (with good reason) on an OS threads library. The synchronization primitives
for Java and Pthreads aren't identical, but they're similar. The JVM is more likely to be correct
and perform well if no subtle emulation is required. But I also think it's important that
we minimize divergence between thread models for the benefit of the user. Many people will
need to use both models, or transfer pieces of code from one into the other. Introducing
subtle differences along these lines isn't going to help code correctness.

Based on what I currently understand, I'm also inclined to allow spurious wakeups, unless
portable existing code could reasonably rely on their absence.


> -----Original Message-----
> From:
> []On Behalf Of Martin Trotter
> Sent: Tuesday, November 25, 2003 1:50 AM
> To: Java Memory Model
> Subject: Re: JavaMemoryModel: Reconsidering spurious wakeups
> The problem in general is not that JVMs generate these
> spurious wakeups but
> that they don't attempt to isolate the Java code from spurious wakeups
> generated by the OS. In essence what's being proposed is a
> new layer of
> function on top of the OS facilities (eg pthread_cond_wait)
> which detect
> and correct the spurious wakeup case. In general this is
> going to cost
> performance and include some tricky design issues. I will continue to
> check with other folks but my feeling is that we should allow spurious
> wakeups.
> Martin Trotter
> -------------------------------
> JavaMemoryModel mailing list -
JavaMemoryModel mailing list -

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