User-level threads and Kernel-level threads

Computer EngineeringMCAOperating System

A thread is a lightweight process that can be managed independently by a scheduler. It improves the application performance using parallelism.

A thread shares information like data segment, code segment files etc. with its peer threads while it contains its own registers, stack, counter etc.

The two main types of threads are user-level threads and kernel-level threads. A diagram that demonstrates these is as follows −

User-level threads and Kernel-level threads

User - Level Threads

The user-level threads are implemented by users and the kernel is not aware of the existence of these threads. It handles them as if they were single-threaded processes. User-level threads are small and much faster than kernel level threads. They are represented by a program counter(PC), stack, registers and a small process control block. Also, there is no kernel involvement in synchronization for user-level threads.

Advantages of User-Level Threads

Some of the advantages of user-level threads are as follows −

  • User-level threads are easier and faster to create than kernel-level threads. They can also be more easily managed.
  • User-level threads can be run on any operating system.
  • There are no kernel mode privileges required for thread switching in user-level threads.

Disadvantages of User-Level Threads

Some of the disadvantages of user-level threads are as follows −

  • Multithreaded applications in user-level threads cannot use multiprocessing to their advantage.
  • The entire process is blocked if one user-level thread performs blocking operation.

Kernel-Level Threads

Kernel-level threads are handled by the operating system directly and the thread management is done by the kernel. The context information for the process as well as the process threads is all managed by the kernel. Because of this, kernel-level threads are slower than user-level threads.

Advantages of Kernel-Level Threads

Some of the advantages of kernel-level threads are as follows −

  • Multiple threads of the same process can be scheduled on different processors in kernel-level threads.
  • The kernel routines can also be multithreaded.
  • If a kernel-level thread is blocked, another thread of the same process can be scheduled by the kernel.

Disadvantages of Kernel-Level Threads

Some of the disadvantages of kernel-level threads are as follows −

  • A mode switch to kernel mode is required to transfer control from one thread to another in a process.
  • Kernel-level threads are slower to create as well as manage as compared to user-level threads.
raja
Published on 10-Oct-2018 19:54:04
Advertisements