There are three thread models that are used in thread scheduling implementations usually done by OS Kernels. One of them is the hybrid (M:N
) model in which some N
application threads are mapped to M
kernel threads so that they can use up to M
processors. There are pros and cons to this model. One of the advantages is th开发者_如何学编程at the languages that are based on this model will introduce a language level scheduler implementation that is responsible for management and scheduling the application-level threads.
- I was wondering if anyone knows any effort or a work that already has done this so that a language or library could take advantage of it?
- Considering for instance the fact that Kernel 2.6.23+ uses an algorithm called CFS for scheduling, do you think that this hybrid model would at all be a wise approach to invest on?
First of all read this: http://www.kegel.com/c10k.html#1:1
Linux uses 1:1 threading model starting from kernel 2.6 (NPTL Native Posix threading library) and today almost all OSes move to this model:
- FreeBSD starting from 7.0 if I'm not mistaken.
- Solaris starting for some version also moved to 1:1 - I don't remember which one.
Once Linux had M:N model (this was in 2.4 NGPT) but 1:1 is generally superior.
The biggest problem with M:N model is:
- Hard to implement
- When using blocking system calls you actually need to notify somehow kernel to block only one user space thread and not kernel one
- In age of multi cores you want to have as much kernel threads as you can.
One of them is the hybrid (M:N) model in which some N threads of an application are mapped to some M available processors.
Small correction - N application threads mapped to M kernel threads so they can use up to M processors.
精彩评论