Different OSes have different concurrency subsystems, there are OS processes, POSIX threads and today also "LWP" threads in Linux, Windows has processes, fibers, threads, etc. Each process is scheduling by OS scheduler and gets own quantum of CPU time. This is true for Linux "LWP"s because they are processes but sharing memory space, and it's not true for user-space threads, where all threads share one CPU time quantum.
Haskell has forkIO. I found in the Haskell sources next commentaries:
Scheduling of Haskell threads is done internally in the Haskell runtime system, and doesn't make use of any operating system-supplied thread packages.
also
In terms of performance, 'forkOS' (aka bound) threads are much more expensive than 'forkIO' (aka unbound) threads, because a 'forkOS' thread is tied to a particular OS thread, whereas a 'forkIO' thread can be run by any OS thread. Context-switching between a 'forkOS' thread and a 'forkIO' thread is many times more expensive than between two 'forkIO' threads.
which emphasizes that threads created with forkIO are not scheduling by the OS scheduler. They, as I understand, can be free from common blocking (with -thread option, sure), but however in the case there are 3 open questions for me:
- how do they ("threads" created with forkIO) share those CPU quantum?
- will they be guaranteed to be distributed to different cores or, since they are represented by one process, no? Or is this non-deterministic behavior?
- Am I right that to avoid interference effects is better to use
forkOSthanforkIO? I mean if I have 2 threads and one of them serves HTTP and another one makes heavy disk I/O operation, then better solution will be to useforkOSthanforkIO?