I am wondering whether it is possible for a new thread to be created in foreign code by some other library and for the new thread to call back into ML.  As the new thread would not be created by Poly/ML, presumably it would not have its own ML stack and that sounds problematic, given the description in the original paper [1].  On the other hand, perhaps an ML stack is provided by the callback closure.  I briefly looked at the source code, and ended up at buildCallBack in X86ForeignCall.ML, but I would need to understand the code generation to make sense of that.

Phil


1.Efficient Parallel Programming in Poly/ML and Isabelle/ML

...

Like every thread that runs ML code this new thread has both
an operating-system stack that it uses when running in the RTS or
in “foreign” code through the foreign-function interface (FFI) and
an ML stack that is used when running ML code. The ML stack is
an object within the ML heap and can be scanned and updated by
the garbage-collector.

...

Because all threads are created by calls to the RTS and all
interaction with the operating system is through it the RTS is able
to maintain a table of threads and their current state. Knowing the
state of all threads is particularly important for garbage collection.

...

_______________________________________________
polyml mailing list
polyml@inf.ed.ac.uk
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml

Reply via email to