Types of Threads | User level threads | Kernel level threads

Types of Threads

Generally, a process can have one or more threads. There are two types of threads:

  1. User level threads: User level threads are not known to kernel and these managed at user level.

  2. Kernel level threads: Kernel level threads are scheduled by Operating System and managed at kernel level.

Threads | User Level Thread | Kernel Level Thread

Thread: Thread is a lightweight process which provides a way to improve application performance through parallelism. It provides concurrency within a process.Thread is an execution unit which consists of its own program counter, a stack, and a set of registers.
Types of Thread:
User Level Thread
2. Kernel Level Thread

User Level Thread

Kernel Level Thread

Implemented by thread library in user mode.

Implemented by O.S.  in Kernel mode.



Generic and can run on any O.S.

Kernel- level thread is specific to the O.S.

Multithreading Models:
In a specific implementation, the user threads must be mapped to kernel threads, using one of the following strategies:
1. Many to one relationship // many user-level threads are all mapped onto a single kernel thread.
2. One to one relationship // a separate kernel thread to handle each user thread.
3. Many to many relationship // multiplexes any number of user threads onto an equal or smaller number of kernel threads, combining the best features of the one-to-one and many-to-one models.