0% found this document useful (0 votes)
23 views

Threads in Operating System

Uploaded by

Debdutta Mandal
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
0% found this document useful (0 votes)
23 views

Threads in Operating System

Uploaded by

Debdutta Mandal
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
You are on page 1/ 3

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:
It takes far less time to create a new thread in an existing process than to create a new process.

Threads can share the common data; they do not need to use Inter- Process communication.

Context switching is faster when working with threads.

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


The user threads can be easily implemented than the kernel thread.

User-level threads can be applied to such types of operating systems that do not support threads at
the kernel-level.

It is faster and efficient.

Context switch time is shorter than the kernel-level threads.

It does not require modifications of the operating system.

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.

It is simple to create, switch, and synchronize threads without the intervention of the process.

Disadvantages of User-level threads


User-level threads lack coordination between the thread and the kernel.

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

You might also like