Threads in Operating System
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.
Types of Threads
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
User-level threads can be applied to such types of operating systems that do not support threads at
the kernel-level.
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.
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.