[MLton] cvs commit: critical sections during thread switch

Matthew Fluet fluet@cs.cornell.edu
Sun, 4 Apr 2004 20:21:41 -0400 (EDT)


> It seems reasonable to me change things and to treat the stack
> invariant like we treat the frontier invariant.  That is, we could
> change stackTopIsOK for inactive stacks to
>
> 	stackTop (s) <= endOfStack (s) - maxFrameSize + topFrameSize (s)
>
> This would automatically be true for threads that call GC_gc, so there
> would be no need to do a GC for the current thread to grow its stack.

I think I'm with you up to here.

> We would then need to check when switching to a thread that the
> stronger condition holds
>
> 	stackTop (s) <= endOfStack (s) - maxFrameSize + topFrameSize (s)
>
> for the thread being switched to.   We could check this just like we
> check ensureFree (bytesNeeded) for the thread being switched to.

Now I'm totally lost.  Did you mean the strong invariant:

	stackTop (s) <= stackLimit (s)
		===
	stackTop (s) + 2 * maxFrameSize <= endOfStack (s)

> This approach seems a bit more uniform than what we currently do.

Agreed.