What are multithreading models?

Operating SystemHardwareSoftware & Coding

Threads that are available at user level are called as user threads. Threads available at kernel level are called kernel threads. User threads are supported above the kernel and are managed without kernel support and kernel threads are supported and managed directly by the operating system.

Types of multithreading models

The different types of multithreading models are as follows −

Many-to-one model

It maps many user threads to one kernel thread. The thread management is based on the thread library in user space, because of this it is efficient but the entire process is going to block if a thread makes a blocking system call.

So, only one thread can access the kernel space at a time, multiple threads are unable to run in parallel on the multiprocessor.

The diagram of many-to-one model is as follows −

One-to-one model

It maps every user thread to a kernel thread. It provides more concurrency than a many-to-one model by allowing another thread to run when a thread makes a blocking system call. It allows multiple threads to run in parallel on a multiprocessor.

The drawback of this model is that creating a user thread requires creating the corresponding kernel thread, so the overhead of creating kernel threads can burden the performance of an application.

The examples include Linux, Windows.

The diagram of one-to-one model is as follows −

Many-to-Many model

It multiplexes many user level threads to a smaller or equal number of kernel threads. The number of kernel threads may be specific to either a particular application. And many-to-one models allow the developer to create as many user threads and true concurrency is not gained because the kernel can schedule only one thread at a time.

Whereas one-to-one model allows greater concurrency but the developers are not creating many threads with an application.

So, finally the many-to-many overcome all these problems. Here developers create as many user threads as necessary and the corresponding kernel threads can run in parallel on a multiprocessor. When a thread performs a blocking system call, the kernel can schedule another thread for execution.

The diagram of many-to-many model is as follows −

Updated on 30-Nov-2021 12:26:51