/    /  OS – Multithreading Models

Multi-threading models

 

Multithreading allows the execution of multiple parts or threads of a program at the same time. Multithreading fully utilizes the CPU through multitasking. 

 

The different models for multithreading are as follows:

 

 

  • One to one model:

 

 

In this model, there is one to one connection between the user and the kernel, and multiple threads can run on multiple processors. 

Each kernel thread is connected to a different user thread, therefore creating a user thread needs a corresponding kernel thread.

The operating systems Windows and Linux implement one to one multithreading.

 

 

  • Many to one model:

 

 

In many to one model, multiple user threads are mapped to one kernel thread. Unlike one to one model, if the user thread makes a blocking system call, it will block the entire system. 

In this system, only one thread can access the kernel at one time, multiple threads cannot run in parallel.

The Green Threads library of Solaris Operating System implements the many to one model.

 

 

  • Many to many model:

 

 

In many to many model, the number of kernel threads is the same or lesser than the number of user threads. In this model, if one user thread is blocked, we can schedule other user threads to the kernel thread. 

It is also referred to as two-level model and provides efficient and fast thread management. 

Many to many model does not restrict the user from creating as many threads as required.

 

Reference

Models of Multithreading.