THREADS
WHAT IS A THREAD?
• A thread is a basic unit of CPU utilization.
• It comprises a thread ID, a program counter, a
THREAD1
register set, and a stack.
THREAD2
• Based on the no.of threads under each
PROCESS1
process,Processes are classified into two types:
• Single-Threaded process : THREAD2
A traditional (or heavyweight) process has a
THREAD1
single thread of control.
• Multi-Threaded process: THREAD3
If a process has multiple threads of control, it can PROCESS
2
perform more than one task at a time.
• Many software packages that run on modern desktop,PCs are
PROGRAM1
multithreaded.
BENEFITS OF MULTITHREADED
• PROGRAMMING:
Responsiveness: Multithreading an interactive
application may allow a program to continue running
even if part of it is blocked or is performing a lengthy
operation, thereby increasing responsiveness to the user.
• Resource sharing: Processes may only share
resources through techniques such as shared memory or
message passing. However, threads share the memory
and the resources of the process to which they belong by
default.
• Economy: Allocating memory and resources for
process creation is costly. Because threads share the
resources of the process to which they belong, it is
more economical to create and context-switch threads.
• Scalability: The benefits of multithreading can be
greatly increased in a multiprocessor architecture,
where threads may be running in parallel on different
processors.
MULTI-THREADING MODELS:
TYPES OF THREADS:
1.USER-LEVEL THREADS: Supported over kernel threads and managed by thread libraries and
doesn’t require kernel support.
2.KERNEL-LEVEL THREADS: Supported and managed directly by operating system using system
calls.
1. ONE-TO-MANY MODEL:
• Many-to-One Mapping.
• User-Level Management.
• Blocking Issue.
• No True Parallelism.
2. ONE-TO-ONE MODEL:
• User-Kernel Mapping
• Increased Concurrency
• Blocking Call Handling
• Parallel Execution
• Thread Creation Overhead
• Thread Limitation
3. MANY-TO-ONE MODEL:
• Thread Multiplexing
• Kernel Thread
Flexibility
• Parallel Execution
CONCLUSION:
• Threads allow programs to run multiple tasks concurrently, improving
resource utilization and performance, especially on multiprocessor
systems.
• The choice of threading model impacts efficiency, with different models
offering unique trade-offs in terms of concurrency, system overhead, and
application performance.
Thank you!