[Gc] Re: External thread suspension (again)
keiths at redhat.com
Mon Jun 5 13:43:01 PDT 2006
Hans Boehm wrote:
> Some comments/questions:
> 1) I don't see where the SUSPENDED flag gets set in response to
> GC_suspend_thread. It gets set in GC_suspend_self(), but I don't
> think you get there unless it has already been set?
That gets set in GC_suspend_self. When GC_stop_world is called,
GC_suspend_all will not signal the externally suspended thread (because
GC_start_blocking will set thread_blocked).
> 2) You should probably call GC_brief_async_signal_safe_sleep().
> Last time I looked nanosleep wasn't technically async-signal-safe,
> but I think select() always has been.
I've changed that. Thanks.
> 3) Have you thought about the various possible signal races, and which
> signals are masked at what point? I haven't yet had a chance to. It
> may be fine, but if there's an obvious argument that it is, a
> comment would be great.
I've thought about it a bit, and the only problem that I see is in the
signal handler code. *If* a non-blocked signal were to make it to an
externally suspended thread (and we ended up in our signal handler), it
would GC_suspend_self itself again. In which case, we would need to
differentiate between a thread that is supposed to suspend itself and a
thread which is already suspended.
But since we only install a signal handler for SUSPEND and THR_RESTART,
so it shouldn't be an issue. A suspended thread should not get
THR_RESTART, since blocked_thread is set by GC_start_blocking.
Or at least, that's all I could divine.
> 4) IIRC, GC_start_blocking() has a fundamental issue in that there isn't
> really a good way to guarantee that all callee-saves registers are visible
> onthe stack at the right point. The result might be very occasional
> failures. So long as this is used only for debugging, and since this
> is fixed with an interface change in 7.0, which can be easily accomodated
> by your patch, I'd lean towards ignoring this for now. The more
> ambitious, and more correct, solution would be to backport the gc7
> do_blocking() code.
Okay, I will keep that in mind.
I've attached the latest revision of this patch.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 3338 bytes
Desc: not available
Url : http://napali.hpl.hp.com/pipermail/gc/attachments/20060605/9ddd6aba/external-suspend.bin
More information about the Gc