Multithreading – implementation of mixed threading model (M: n)
Three threads model is usually used in the implementation of thread scheduling completed by OS kernel One of them is the hybrid (M: n) model, in which some N application threads map to m kernel threads, so they can use up to m processors This model has advantages and disadvantages One advantage is that the language based on this model will be introduced into the language level scheduler implementation, which is responsible for managing and scheduling application level threads
>I wonder if anyone knows of any efforts or has completed this work so that the language or library can use it? > Consider, for example, kernel 2.6 23 with the fact that an algorithm called CFS is used for scheduling, do you think this hybrid model is a wise investment?
Solution
First read: http://www.kegel.com/c10k.html#1:1
Linux uses the 1:1 threading model starting from kernel 2.6 (NPTL native POSIX Thread Library), and almost all operating systems today have moved to this model:
>If I'm not mistaken, FreeBSD starts with 7.0. > Some versions of Solaris have also started moving to 1:1 - I don't remember which one
Once Linux has the M: n model (which is in 2.4 ngpt), 1:1 is usually superior
M: The biggest problem of N model is:
>Difficult to implement > when blocking system calls, you actually need to notify a kernel to block only one user space thread instead of the kernel > in the multi-core era, you want to have as many kernel threads as possible
Minor fix - N application threads map to m kernel threads, so they can use up to m processors