[MLton] Re: [MLton-user] FFI and pointer relocation

Daniel Spoonhower spoons+ at cs.cmu.edu
Wed Nov 28 10:15:58 PST 2007


Henry Cejtin wrote:
> Watch  out:  having  a  single global value where the the time is transferred will cause problems with multiple threads.
> We really need something like the once function that is more  efficient  for this or some kind of atomic region.

And even more problems with multiple processors!  The use of _symbol and
_address for mutable data have been a real headache for me in my parallel
implementation.  I have been doing something ad hoc for cases of _symbol that
I use, but I have been meaning to consider a more general solution.

One option is something like _symbol that allows access to fields in GC_state.
 This could be compiled efficiently for single processor binaries (where
gcState can be statically allocated), but dispatch based on the current
processor in parallel binaries (where there is one GC_state per processor).
(Though we would still need a solution like Henry suggests to handle thread
switches on a given processor.)

It would be even better if we could heap allocate things like timevals.  The
use of global mutable state is a problem for any parallel implementation, and
I think it makes hacking on the runtime more difficult in general.


--djs





More information about the MLton mailing list