- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
User-level threads and Kernel-level threads
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
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.
- Related Articles
- Actions taken by a kernel to context-switch between kernel-level threads.
- Difference Between Daemon Threads and User Threads In Java
- Threads in C#
- Implicit Threading and Language-based threads
- Threads and Thread Synchronization in C#
- Joining Threads in Java
- Synchronizing Threads in Python
- Killing threads in Java
- Minimum and Maximum Priority Threads in Java
- Using Threads in Rust Programming
- Threads vs Processes in Linux
- How to destroy threads in C#?
- How to use multiple threads in android?
- How to handle Python exception in Threads?
- Difference between system level exception and Application level exception.
