Adv Os
Adv Os
Adv Os
USER-LEVEL
THREAD
CONTENTS
About threads in the operating system.
Components of threads.
Why do we need them?
Types of threads:
User-level thread
Benefits of threads.
WHAT IS THREAD IN OPERATING
SYSTEMS?
In a process, a thread refers to a single sequential activity being
executed, and these activities are also known as “thread of
execution” or “thread control”.
Threads are also called “lightweight processes” as they possess
some of the properties of processes.
Any operating system process can execute a thread, and a
process can have multiple threads.
Each thread of the same process uses a separate program counter
and a stack of activation records and control blocks.
Threads can be effective only if the CPU is more than 1;
otherwise, two threads must context switch for that single CPU.
COMPONENTS OF
THREADS
These are the basic components of the Operating System.
Stack Space
Register Set
Program Counter
Thread ID
WHY DO WE NEED
THREAD?
It takes far less time to create a new thread in an
existing process than creating a new one.
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 OPERATING
SYSTEM
Threads are of two types.
User Level Thread
Kernel Level Thread
USER LEVEL THREADS
User Level Thread is a type of thread that is not created using
system calls.
The kernel does not manage user-level threads.
The user can easily implement user-level threads.
In case when user-level threads are single-handed processes,
kernel-level thread manages them.
Here are some examples of user-level threads:
• Java thread
• Python user-level threads
ADVANTAGES OF USER-LEVEL
THREADS
The user threads can be more 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 more efficient.
Context switch time is shorter than the kernel-level threads.
It does not require modifications of the operating system.
User-level thread 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.
BENEFITS OF THREADS
Enhanced throughput of the system
Effective Utilization of Multiprocessor System
Faster context switch
Responsiveness
Communication
Resource sharing
DIFFERENCE BETWEEN
PROCESS AND THREAD:
PROCESS THREAD
Process means any program is in Thread means a segment of a process.
execution.
More time is needed to terminate, Less time is needed to terminate, create,
create, and switch contexts. and switch contexts.