I have been following a course on Operating Systems over the past few months. However, I'd like some clarification on one point that I read. From my understanding, there are three types of multithreading models to map user level threads to kernel level threads -
I can see why the many to one model is not very efficient when it comes to parallel processing - because a blocking system call would mean halting of any processing.
However, in the book I'm referring, Operating System Concepts (By Abraham Silberschatz, Greg Gagne and Peter Galvin), it says that both Linux and the Windows family use the one to one model, even though there is the extra overhead of creating a kernel thread for every user thread that's created.
Wouldn't a many to many model be better? Because you have a number of kernel threads, sufficient to have a high degree of parallelism, and you can always opt for a two level model to bind a user level thread to a kernel level thread.
TLDR: Why is the one to one multithreading model preferred over many to many model despite the overhead in Windows and Linux systems?
Wouldn't a many to many model be better?
I'd suggest getting another book. AFAIK the Many-to-Many model is entirely theoretical (If someone knows of a system that uses it, please indicate in a comment). These models are a very poor way of explaining threads.
In ye olde days operating system had no concept of threads. They scheduled processes for execution. In fact, this is still the case for many operating systems.
The need for threads was largely driven by the Ada programming language that required "task" support. In order to have a compliant Ada implementation there had to be a library that simulated threads within a single process. In such a system a process schedules its own thread execution ("user threads). This has the drawback that the threads always run interleaved (never in parallel on different processors).
This is being called "many to one" but that is a poor description of what is happening. Your model calls that "many user threads" are being mapped to a single "kernel thread." In reality, there are no kernel threads. Instead threads are being implemented in the context of a process.
It has become common for operating systems to view processes as an address space with multiple schedulable threads of execution. in such a system the thread is the basic unit of scheduling; not the process. Is is the one-to-one model in your scheme.
it says that both Linux and the Windows family use the one to one model, even though there is the extra overhead of creating a kernel thread for every user thread that's created.
This is kind of BS.There is overhead for a thread no matter how they are implemented. You will often find people claiming that "Many-to-One" is more efficient than "One-to-One." This claim appears to be just urban legend.
Why is the one to one multithreading model preferred over many to many model despite the overhead in Windows and Linux systems?
The "one-to-one" (aka kernel threads) model is preferable because it takes advantage of multiple processors and allows actual execution in parallel. It also avoids blocking problems that can occur in some systems (e.g. Eunuchs).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With