New Bound Threads Proposal

Wolfgang Thaller wolfgang.thaller at gmx.net
Mon Apr 28 07:40:50 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.

> But only B is runnable (which is why I said only one *runnable* Haskell
> thread may be bound to any given native thread, but I see you removed
> that word when you added the statement to the document).

I removed the word runnable
a) to try to stick with the terminology used in the formal semantics; 
mixing two concepts of when a thread is created and when it is 
destroyed would be confusing.
b) because it's not entirely correct; instead of "runnable", it is "not 
blocked on a foreign call".
(There must not be two threads that are blocked on MVars and bound to 
or associated with the same native thread).

Is that OK with you? (Perhaps we could add a clarifying footnote; but I 
have no idea how to put it without confusing people even more).

Cheers,

Wolfgang




More information about the FFI mailing list