New Bound Threads Proposal
Simon Marlow
simonmar at microsoft.com
Mon Apr 28 07:58:07 EDT 2003
> > Hmmm - what about the following situation:
> >
> > - Haskell thread A is bound to native thread N
> > - Haskell thread A makes an FFI call
> > - the FFI call invokes a foreign export, creating Haskell thread B
> > - Haskell thread B calls threadbound()
> >
> > at this point A & B are both bound to the same native thread, right?
>
> No. In the formal semantics, Haskell thread A ceases to exist at the
> moment it makes an FFI call.
> This is an area where we always had many misunderstandings.
> In the GHC
> runtime, yes, A & B would
> both be bound to the same native thread, but A would be
> "BlockedOnCCall". Other people might also
> consider A and B to be the same thread.
Urk. Ok, I can see the logic in treating A & B as the same thread. The
semantics doesn't model the identity of Haskell threads, so it's
difficult to say what we mean by "the same thread" anyway.
Note that in practice you can actually observe whether A & B are the
same Haskell thread or not, using myThreadId, so if the semantics were
to model myThreadId it would have to explicitly allow A & B to have the
same ThreadId. I'm not saying we should do this, just that it's
something to bear in mind.
Cheers,
Simon
More information about the FFI
mailing list