Weldon, thanks for the review.
Weldon Washburn wrote:
> I tried to apply your below patch to the current svn HEAD. It looks like
> your local source tree is out of date. The patch failed.
I've attached the updated patch to HARMONY-1951. The scheme of notify_flag
modification is different from the original suggestion, and I think it
is better in that it is not suffering from potential 'lost notify' problem.
> The do while {...} might actually need to make a call to
> hythread_safe_point() somewhere in the loop. I worry about GC latency. I
> haven't thought about this too carefully.
I agree, this is an important thing to think about.
Luckily, in this particular case we are delegating actual wait
work to
condvar_wait_impl()
which already takes care of the suspend disable/enable model, specifically,
it resets the suspend disabled counter to 0 before blocking by
reset_suspend_disable()
and restores the original value back by
set_suspend_disable(disable_count),
which in turn calls thread_safe_point_impl() as needed.
> As far as I can tell, your patch does not address the situation where the
> targetted threads appear to miss the interrupt from the main thread. Am I
> correct?
The patch addresses the issues of spurious wakeups resulting from interrupts.
I have not tried to do anything to do to missing interrupts, because
specification says nothing about it, and
I think there is not much of "not-missing-interrupt" user expectations we
should care about.
(In contrast with spurious wakeups, which are spec-compliant but very much
surprising)