multithreaded-process-benefits

Multithreaded Process: Benefits & Models

Hello Friends, In this blog post I am going to explain to you the benefits of the multithreaded process and types of its model.

Benefits: The benefits of multithreaded programming can be broken into the following categories –

Resource sharing: By default, threads share the memory and the resources of the process to which they belong. The benefit of code sharing is that it allows an application to have several different threads of activity all within the same address space.

Responsiveness: multithreading an interactive application may allow a program to continue running even if part of it is blocked or is performing a lengthy operation, thereby increasing responsiveness to the user.

Economy: It is costly to allocate memory and resources for process creation. Alternatively, it is more economical to create and context switch threads because threads share resources of the process to which they belong.

Utilization of multiprocessor architecture: The benefits of multithreading can be increased in a multiprocessor architecture, where each thread may be running in parallel on a different processor.

Types of model:

There are many systems that provide support for both user and kernel threads, resulting in different multithreading models. There are following types of multithreading implementation –

Many to one model:

The many to one model maps many user-level threads to one kernel thread as shown in fig 1 thread management is done in userspace, so it is efficient, but the entire process will block if a thread makes a blocking system call. Also, multiple threads are unable to run in parallel on a multiprocessor, because only one thread can access the kernel at a time. For example, green threads- a thread library available for Solaris 2- uses this model.

multithreaded-process

One to one model:

The one to one model maps each user thread to a kernel. It provides more concurrency than the many to one model by allowing another thread to run when a thread makes a blocking system call. It also allows multiple threads to run in parallel on multiprocessors. The drawback to this model is that creating a user a user thread requires creating the corresponding kernel thread.

Because the overhead of creating kernel threads can burden the performance of an application, implementation of this model restricts the number of threads supported by the system. For example, Windows NT, Windows 2000 and OS/2 implement this model.

Many to many models:

The many to many model 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 or a particular machine. Whereas the many many to model allow the developer to create as many user threads as he wishes, true concurrency is not gained because the kernel can schedule only one thread at a time.

manytomany-multithreading

The one to one model allows greater concurrency, but the developer has to be careful not to create so many threads within an application. The many to many models do not suffer from these drawbacks.

Developers can create as many user threads as required, and the corresponding kernel threads can run in parallel on a multiprocessor. For example, salaries 2 IRI X and Tru64 UNIX implement this model.

In the case of any queries, you can write to us at a5theorys@gmail.com we will get back to you ASAP.

Hope! you would have enjoyed this post about multithreaded process benefits and types of multithreaded process models.

Please feel free to give your important feedbacks in the comment section below.

Have a great time! Sayonara!