[MLton] Re: [MLton-user] ffi newbie (fwd)

Matthew Fluet fluet at tti-c.org
Mon Sep 10 14:30:05 PDT 2007


On Fri, 7 Sep 2007, Henry Cejtin wrote:
> I'm confused why calling an _export-ed function introduces another thread of
> control.  Is this just done because the exported ML function might need some
> more C stack?

Its simply the implementation of _export-ed functions.  There is a 
distinguished ML thread that is invoked when an _export-ed function is 
called; and, for each invoked function, a new ML thread is created to 
evaluate the ML code.  See <src>/basis-library/thread.sml and the 
'register' function.

> My point is that from the point of optimization, I would think that ML calling
> C calling ML would still obey all the single-threaded constraints.

That's true, though from the point of view of the compiler, it won't 
distinguish between threads used just for _export-ed functions and a 
general use of threads.




More information about the MLton mailing list