Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Notes  >  Operating System  >  Threads & Its Types - User Level Thread & Kernel Level Thread

Threads & Its Types - User Level Thread & Kernel Level Thread

Thread in Operating System

What is a Thread?
A thread is a path of execution within a process. A process can contain multiple threads.

Process vs Thread
The primary difference is that threads within the same process run in a shared memory space, while processes run in separate memory spaces.
Threads are not independent of one another like processes are, and as a result threads share with other threads their code section, data section, and OS resources (like open files and signals). But, like process, a thread has its own program counter (PC), register set, and stack space.

Advantages of Thread over Process

  1. Responsiveness: If the process is divided into multiple threads, if one thread completes its execution, then its output can be immediately returned.
  2. Faster context switch: Context switch time between threads is lower compared to process context switch. Process context switching requires more overhead from the CPU.
  3. Effective utilization of multiprocessor system: If we have multiple threads in a single process, then we can schedule multiple threads on multiple processor. This will make process execution faster.
  4. Resource sharing: Resources like code, data, and files can be shared among all threads within a process.
    Note: stack and registers can't be shared among the threads. Each thread has its own stack and registers.
  5. Communication: Communication between multiple threads is easier, as the threads shares common address space. while in process we have to follow some specific communication technique for communication between two process.
  6. Enhanced throughput of the system: If a process is divided into multiple threads, and each thread function is considered as one job, then the number of jobs completed per unit of time is increased, thus increasing the throughput of the system.

Threads are executed one after another but gives the illusion as if they are executing in parallel. Each thread has different states. Each thread has

  1. A program counter
  2. A register set
  3. A stack space

Threads are not independent of each other as they share the code, data, OS resources etc.

Similarity between Threads and Processes

  1. Only one thread or process is active at a time
  2. Within process both execute sequentiall
  3. Both can create children

Differences between Threads and Processes

  1. Threads are not independent, processes are.
  2. Threads are designed to assist each other, processes may or may not do it

Types of Threads

There are two types of threads.

  1. User Level Thread
  2. Kernel Level Thread

1. User Level thread (ULT): Is implemented in the user level library, they are not created using the system calls. Thread switching does not need to call OS and to cause interrupt to Kernel. Kernel doesn't know about the user level thread and manages them as if they were single-threaded processes.

(i) Advantages of ULT

  • Can be implemented on an OS that does't support multithreading.
  • Simple representation since thread has only program counter, register set, stack space.
  • Simple to create since no intervention of kernel.
  • Thread switching is fast since no OS calls need to be made.

(ii) Disadvantages of ULT

  • No or less co-ordination among the threads and Kernel.
  • If one thread causes a page fault, the entire process blocks.

2. Kernel Level Thread (KLT): Kernel knows and manages the threads. Instead of thread table in each process, the kernel itself has thread table (a master one) that keeps track of all the threads in the system. In addition kernel also maintains the traditional process table to keep track of the processes. OS kernel provides system call to create and manage threads.

(i) Advantages of KLT

  • Since kernel has full knowledge about the threads in the system, scheduler may decide to give more time to processes having large number of threads.
  • Good for applications that frequently block.

(ii) Disadvantages of KLT

  • Slow and inefficient.
  • It requires thread control block so it is an overhead.

Difference between User Level thread and Kernel Level thread

Types of ThreadsTypes of Threads

The document Threads & Its Types - User Level Thread & Kernel Level Thread is a part of the Computer Science Engineering (CSE) Course Operating System.
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)

FAQs on Threads & Its Types - User Level Thread & Kernel Level Thread

1. What's the difference between user level threads and kernel level threads in operating systems?
Ans. User-level threads are managed by user applications without OS involvement, making them lightweight and faster to create. Kernel-level threads are managed directly by the operating system kernel, providing true parallelism on multi-core processors. User-level threads cannot run truly parallel on single-core systems, while kernel-level threads can execute simultaneously across multiple CPU cores, making them superior for concurrent processing in modern systems.
2. Why do user level threads cause the entire process to block when one thread performs I/O operations?
Ans. User-level thread libraries lack kernel awareness-the OS cannot distinguish between individual threads within a process. When a single user-level thread makes a blocking system call like file reading, the kernel blocks the entire process, suspending all threads inside it simultaneously. This occurs because the thread scheduler resides in user space, not kernel space, preventing selective thread management. Kernel-level threads avoid this issue since the OS can block specific threads independently while keeping others active.
3. How do kernel level threads provide better concurrency compared to user level threads?
Ans. Kernel-level threads achieve genuine parallelism because the OS scheduler treats each thread as an independent schedulable entity. Multiple kernel threads can execute simultaneously on different CPU cores without blocking entire processes. The kernel maintains separate state and context for each thread, enabling fine-grained scheduling decisions. User-level threads lack this OS support, restricting true concurrent execution to time-sharing on a single core, making kernel threads ideal for multi-threaded applications requiring high concurrency performance.
4. What are the main advantages and disadvantages of implementing user level threads over kernel level threads?
Ans. User-level threads offer faster context switching, lower overhead in thread creation, and simplified scheduling logic without OS intervention. However, they suffer from blocking problems, inability to utilise multiple processors, and complex implementation of thread libraries. Kernel-level threads provide true parallelism and multiprocessor support but incur higher context-switching overhead and consume more system resources. Choosing between them depends on application requirements-user-level threads suit I/O-bound applications with minimal blocking, while kernel threads benefit compute-intensive, multi-core workloads requiring maximum concurrency.
5. Can user level threads and kernel level threads be used together in a hybrid threading model?
Ans. Yes, hybrid threading combines both approaches-multiple user-level threads map onto fewer kernel-level threads through a many-to-many model. This reduces OS overhead while avoiding blocking issues by allowing the kernel to schedule multiple kernel threads independently. When one user-level thread blocks, only its associated kernel thread pauses, keeping other kernel threads active. This strategy balances efficiency and concurrency, enabling applications to benefit from lightweight user-space scheduling alongside kernel's true parallelism capabilities.
Explore Courses for Computer Science Engineering (CSE) exam
Get EduRev Notes directly in your Google search
Related Searches
MCQs, Important questions, Semester Notes, Threads & Its Types - User Level Thread & Kernel Level Thread, Sample Paper, pdf , Threads & Its Types - User Level Thread & Kernel Level Thread, video lectures, Objective type Questions, practice quizzes, Free, Viva Questions, mock tests for examination, study material, Extra Questions, Exam, Threads & Its Types - User Level Thread & Kernel Level Thread, Summary, past year papers, Previous Year Questions with Solutions, ppt, shortcuts and tricks;