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 four types of multithreading models to map user level threads to kernel level threads -
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).