100% found this document useful (1 vote)
375 views3 pages

User vs Kernel Threads in OS

Threads are sequences of execution within a process that allow a process to split its workload across multiple simultaneously executing threads. Each thread has its own program counter, stack, and control blocks but threads within a process can share common data. There are two types of threads - kernel threads that the operating system schedules and manages, and user-level threads that are scheduled by user-level libraries instead of the kernel. Kernel threads provide better coordination with the operating system while user-level threads have lower overhead. Threads provide benefits like increased system throughput, better utilization of multiprocessor systems, and faster context switching compared to processes.

Uploaded by

Rishabh Malik
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
375 views3 pages

User vs Kernel Threads in OS

Threads are sequences of execution within a process that allow a process to split its workload across multiple simultaneously executing threads. Each thread has its own program counter, stack, and control blocks but threads within a process can share common data. There are two types of threads - kernel threads that the operating system schedules and manages, and user-level threads that are scheduled by user-level libraries instead of the kernel. Kernel threads provide better coordination with the operating system while user-level threads have lower overhead. Threads provide benefits like increased system throughput, better utilization of multiprocessor systems, and faster context switching compared to processes.

Uploaded by

Rishabh Malik
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
  • Process & Thread Kernel Data Structure
  • User-level Thread
  • Kernel-level Thread

Unit 3

Process & Thread Kernel Data Structure


Threads in Operating System
A thread is a single sequential flow of execution of tasks of a process so it is also known as thread of execution or thread of control.
There is a way of thread execution inside the process of any operating system. Apart from this, there can be more than one thread
inside a process. Each thread of the same process makes use of a separate program counter and a stack of activation records and
control blocks. Thread is often referred to as a lightweight process.

The process can be split down into so many threads. For example, in a browser, many tabs can be viewed as threads. MS Word uses
many threads - formatting text from one thread, processing input from another thread, etc.

Need of Thread:
o It takes far less time to create a new thread in an existing process than to create a new process.
o Threads can share the common data, they do not need to use Inter- Process communication.
o Context switching is faster when working with threads.
o It takes less time to terminate a thread than a process.

Types of Threads
In the operating system, there are two types of threads. 1. Kernel level thread. 2. User-level thread.
User-level thread
The operating system does not recognize the user-level thread. User threads can be easily implemented and it is implemented by the
user. If a user performs a user-level thread blocking operation, the whole process is blocked. The kernel level thread does not know
nothing about the user level thread. The kernel-level thread manages user-level threads as if they are single-threaded
processes?examples: Java thread, POSIX threads, etc.
Advantages of User-level threads
1. The user threads can be easily implemented than the kernel thread.
2. User-level threads can be applied to such types of operating systems that do not support threads at the kernel-level.
3. It is faster and efficient.
4. Context switch time is shorter than the kernel-level threads.
5. It does not require modifications of the operating system.
6. User-level threads representation is very simple. The register, PC, stack, and mini thread control blocks are stored in the
address space of the user-level process.
7. It is simple to create, switch, and synchronize threads without the intervention of the process.
Disadvantages of User-level threads
1. User-level threads lack coordination between the thread and the kernel.
2. If a thread causes a page fault, the entire process is blocked.

Kernel level thread


The kernel thread recognizes the operating system. There is a thread control block and process control block in the system for each
thread and process in the kernel-level thread. The kernel-level thread is implemented by the operating system. The kernel knows about
all the threads and manages them. The kernel-level thread offers a system call to create and manage the threads from user-space. The
implementation of kernel threads is more difficult than the user thread. Context switch time is longer in the kernel thread. If a kernel
thread performs a blocking operation, the Banky thread execution can continue. Example: Window Solaris.
Advantages of Kernel-level threads

 The kernel-level thread is fully aware of all threads.


 The scheduler may decide to spend more CPU time in the process of threads being large numerical.
 The kernel-level thread is good for those applications that block the frequency.
Disadvantages of Kernel-level threads

 The kernel thread manages and schedules all threads.


 The implementation of kernel threads is difficult than the user thread.
 The kernel-level thread is slower than user-level threads.
Components of Threads
Any thread has the following components. 1. Program counter 2. Register set 3. Stack space
Benefits of Threads

 Enhanced throughput of the system: When the process is split into many threads, and each thread is treated as a job, the
number of jobs done in the unit time increases. That is why the throughput of the system also increases.
 Effective Utilization of Multiprocessor system: When you have more than one thread in one process, you can schedule more
than one thread in more than one processor.
 Faster context switch: The context switching period between threads is less than the process context switching. The process
context switch means more overhead for the CPU.
 Responsiveness: When the process is split into several threads, and when a thread completes its execution, that process can be
responded to as soon as possible.
 Communication: Multiple-thread communication is simple because the threads share the same address space, while in process,
we adopt just a few exclusive communication strategies for communication between two processes.
 Resource sharing: Resources can be shared between all threads within a process, such as code, data, and files. Note: The stack
and register cannot be shared between threads. There is a stack and register for each thread.

Common questions

Powered by AI

Implementing kernel-level threads presents several challenges: they require significant changes to the operating system, involve complex scheduling and management by the kernel, and result in slower execution due to longer context switch times. Despite providing more robust support for blocking operations, these factors make kernel-level thread implementation inherently more difficult and resource-intensive than user-level threads .

User-level threads have several advantages, including easier implementation, applicability in operating systems not supporting kernel-level threads, faster operation, and simpler context switching because they do not require kernel intervention . However, they suffer from a lack of coordination with the kernel, leading to issues such as blocking the entire process when a page fault occurs . Kernel-level threads, on the other hand, are fully managed by the operating system, better supporting blocking operations since they allow other threads to continue execution . Yet, they are harder to implement, slower due to longer context switch times, and require greater system resources .

A multi-threaded operating system benefits from a multiprocessor system because it can assign different threads of the same process to various processors. This parallel execution uses the multiprocessor system to its fullest capacity, achieving higher performance and responsiveness, as multiple threads can execute simultaneously .

Resource sharing in multi-threading is significant because all threads in a process have access to shared resources such as code, data, and files. This sharing allows threads to communicate efficiently and effectively, reducing the need for resource duplication and minimizing memory usage. It enhances system performance by lowering the overhead for resource management and simplifying context switching .

The essential components of a thread include a program counter, which tracks the execution point; a register set, which stores the current working variables for a thread; and stack space, which maintains the execution history and supports method calls and local variables .

The structure of a thread facilitates efficient execution through its program counter, which ensures the correct sequence of operations; its register set, which holds the current processing data for rapid access; and its stack space, which supports the execution history and local storage needs. This organization allows threads to manage execution efficiently and switch contexts with minimal overhead .

The lack of kernel awareness in user-level threads can lead to issues such as the entire process being blocked if a thread causes a page fault since the kernel perceives the process as single-threaded. This can severely impact system responsiveness and efficiency, particularly in high-demand applications that require continuous thread execution within processes .

Threads enhance the system's throughput by allowing a process to be divided into smaller tasks that can execute concurrently. Each thread is treated as a separate job, which increases the number of jobs processed in a given time unit, effectively improving system throughput .

Threads offer faster context switching compared to processes because they share the same address space and other resources like data and files within a process. This results in less overhead during a context switch as only the stack, register set, and program counter need alteration, unlike processes which require a complete state change .

Thread communication is simpler than process communication because threads within the same process share the same address space, allowing them to communicate and share data without complex inter-process communication mechanisms. This shared memory model significantly reduces the overhead of process communication and allows faster and easier data sharing, improving efficiency and responsiveness .

Unit 3 
Process & Thread Kernel Data Structure 
Threads in Operating System 
A thread is a single sequential flow of executio
User-level thread 
The operating system does not recognize the user-level thread. User threads can be easily implemented and
Advantages of Kernel-level threads 
 The kernel-level thread is fully aware of all threads. 
 The scheduler may decide to

You might also like