[MLton] cvs commit: critical sections during thread switch

Matthew Fluet fluet@cs.cornell.edu
Fri, 2 Apr 2004 14:03:47 -0500 (EST)


> > Did you really mean to say that you are forcing a GC when atomic state drops
> > to 0 and a signal is pending?  I don't get why that would be good.
>
> Not a GC, just a call to GC_gc, which will switch to the signal
> handler thread.  A bit confusing, I admit.

And I'll admit I'm not convinced that this really works.  When I read
GC_gc, it seems to me that if we really need to GC (i.e., bytesRequested
is greater than limitPlusSlop - frontier) while a signal is pending, then
we will service the GC but return to the current thread, not the signal
handler thread.

Why is
		startHandler (s);
		switchToThread (s, s->signalHandler);
under the else and not under it's own if (s->canHandle == 0 and
s->signalIsPending) ?  That is, shouldn't it be service the GC _and_
switch to the signal handler if necessary, not service the GC _or_ switch.

(Now, the GC_gc call that get's inserted from the translation of atomicEnd
is o.k., becaue it requests 0 bytes, and we always have slop bytes
available, so we won't GC but will switch to the signal handler.)