Multi Threading Models in Process Management
Multi threading-It is a process of multiple threads executes at same time.
There are two main threading models in process management: user-level threads and kernel-level threads.
User-level threads: In this model, the operating system does not directly support threads. Instead, threads are managed by a user-level thread library, which is part of the application. The library manages the threads and schedules them on available processors. The advantages of user-level threads include greater flexibility and portability, as the application has more control over thread management. However, the disadvantage is that user-level threads are not as efficient as kernel-level threads, as they rely on the application to manage thread scheduling.
Kernel-level threads: In this model, the operating system directly supports threads as part of the kernel. Each thread is a separate entity that can be scheduled and executed independently by the operating system. The advantages of kernel-level threads include better performance and scalability, as the operating system can schedule threads more efficiently. However, the disadvantage is that kernel-level threads are less flexible and portable than user-level threads, as they are managed by the operating system.
There are also hybrid models that combine elements of both user-level and kernel-level threads. For example, some operating systems use a hybrid model called the “two-level model”, where each process has one or more user-level threads, which are mapped to kernel-level threads by the operating system.
Overall, the choice of threading model depends on the requirements of the application and the capabilities of the underlying operating system.
Here are some advantages and disadvantages of each threading model:
Greater flexibility and control: User-level threads provide more control over thread management, as the thread library is part of the application. This allows for more customization and control over thread scheduling.
Portability: User-level threads can be more easily ported to different operating systems, as the thread library is part of the application.
Lower performance: User-level threads rely on the application to manage thread scheduling, which can be less efficient than kernel-level thread scheduling. This can result in lower performance for multithreaded applications.
Limited parallelism: User-level threads are limited to a single processor, as the application has no control over thread scheduling on other processors.
Better performance: Kernel-level threads are managed by the operating system, which can schedule threads more efficiently. This can result in better performance for multithreaded applications.
Greater parallelism: Kernel-level threads can be scheduled on multiple processors, which allows for greater parallelism and better use of available resources.
Less flexibility and control: Kernel-level threads are managed by the operating system, which provides less flexibility and control over thread management compared to user-level threads.
Less portability: Kernel-level threads are more tightly coupled to the operating system, which can make them less portable to different operating systems.
Combines advantages of both models: Hybrid models combine the advantages of user-level and kernel-level threads, providing greater flexibility and control while also improving performance.
More scalable: Hybrid models can scale to larger numbers of threads and processors, which allows for better use of available resources.
More complex: Hybrid models are more complex than either user-level or kernel-level threading, which can make them more difficult to implement and maintain.
Requires more resources: Hybrid models require more resources than either user-level or kernel-level threading, as they require both a thread library and kernel-level support.
Many operating systems support kernel thread and user thread in a combined way. Example of such system is Solaris. Multi threading model are of three types.
Many to many model. Many to one model. one to one model.
Many to Many Model
In this model, we have multiple user threads multiplex to same or lesser number of kernel level threads. Number of kernel level threads are specific to the machine, advantage of this model is if a user thread is blocked we can schedule others user thread to other kernel thread. Thus, System doesn’t block if a particular thread is blocked.
It is the best multi threading model.
Many to One Model
In this model, we have multiple user threads mapped to one kernel thread. In this model when a user thread makes a blocking system call entire process blocks. As we have only one kernel thread and only one user thread can access kernel at a time, so multiple threads are not able access multiprocessor at the same time.
The thread management is done on the user level so it is more efficient.
One to One Model
In this model, one to one relationship between kernel and user thread. In this model multiple thread can run on multiple processor. Problem with this model is that creating a user thread requires the corresponding kernel thread.
As each user thread is connected to different kernel , if any user thread makes a blocking system call, the other user threads won’t be blocked.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
Please Login to comment...