Threading in Operating System

 What is Threading in Operating System?


In operating system threading is very important for multitasking. In this article we will understand about threading in very simple language. 


Threading is way performing multi-tasking in operating system. It is nothing but the clone of the original process which allows to run multiple part of the program concurrently. It works as same as the process (normal process) but the difference is it has it's own process id. Threading is used when all the processes of CPU is completely busy on performing other tasks. These are also called lightweight processes, because they have same code as process have and faster to create and manage. In many of the operating systems threads are very important part of many application.


There are different types of threads used in operating system :-

1. Kernel Thread : Kernel thread is also known as System threads. This threads is managed by the operating system. They are usually used to perform low level tasks such as I/O and memory management. These threads are not visible to user-level applications. Kernel threads are run on the CPU and is scheduled by operating system. Kernel threads have more priority than user-level thread and they are scheduled to run when they are ready.  In some operating systems, kernel threads are created and managed by kernel itself, while in others they can be managed by user-level programs.


2. User Threads : These threads are created and managed by user-level libraries rather than operating system kernel. They are mostly used to perform application level tasks and they are not visible to operating system. These threads are completely used in user space. Hence, they are used in user space that's why they don't require any special privileges. They are dependent on the application in which they are used. They are used to implemented when application need to perform multiple tasks concurrently. Sometimes, user threads are maybe mapped with kernel threads so that operating system allow them to scheduled and run on the CPU. This is known as Multiplexing. 


3. Hybrid Thread : In operating system , a hybrid thread is type of thread that consists of the characteristics of user level thread and kernel level thread. In which user-level  thread and kernel level thread performing their own tasks. But in hybrid thread, the advantages of both threads are combined. This combination allow the operating system to schedule the thread to run on different processors. They also need to allow to create and manage quickly which makes the use of hybrid thread very efficient.


Above information is related to threading and it's types. Hopefully, this article is informative for you.

Comments