If true, that gives us the important principle that
At any one time, there is at most one runnable Haskell thread associated with, or bound to, any given native thread.
Exactly. I'll make sure it's mentioned somewhere. (Also, a Haskell thread cannot be bound to a native thread that already has a different Haskell thread associated with it).
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? 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). Cheers, Simon
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
participants (2)
-
Simon Marlow -
Wolfgang Thaller