I am trying to understand exactly how bound threads are implemented in Haskell.
I can instantiate multiple schedulers by passing in the -N[n]
flag. Are these schedulers executing on individual OS threads?
By using forkOS
from Control.Concurrent
I am create a bound thread. Now, the documentation states that the thread will still be scheduled by the Haskell runtime-system, but it will appear as if it was created using pthread_create
to any foreign functions. How is this actually realized? All foreign calls will be made from the same OS thread so that they can access thread-local state, but is there a chance that multiple bound threads may be pinned to the same OS thread?
I guess I am trying to understand when the actual OS threads are created, and how it is implemented that the Haskell threads appear to be bound.