Native Threads in the RTS

Simon Marlow
Fri, 29 Nov 2002 14:08:12 -0000

> Simon Marlow:
> > Another problem, from an implementation point of view, is that we
> > would have to surround "unsafe" foreign calls with a lot of
> > context-switching gumph, in case the calling Haskell thread is bound
> > to a native thread.  I really think we don't want to do this.
> Note that you only have to do this to foreign calls of the form:
>   foreign import bound foo :: ...
> since any other calls are free to use whatever thread they feel like.

Umm, this is new... the proposal doesn't have "foreign import bound",
although it does have a parenthetical comment that indicates that it
might be considered:

   There are now two kinds of foreign exported [and foreign import=20
   wrapped] functions: bound and free.

and later on:

   When a foreign imported function is invoked [by Haskell code], the=20
   foreign code is executed in the native thread associated with the =20
   current Haskell thread, ...

So currently the idea is that every foreign import is executed by the
native thread bound to the current Haskell thread, if any.

This is all getting highly confusing, as it seems we're working with
different ideas of what's on the table.  Alastair: you seem to be
working on your own proposal - could you write it down either as a
complete proposal or diffs to Wolfgangs?