Page 1
T h r e a d s
Page 2
T h r e a d s
What is a Thread?
Thread Definition
A thread is a path of execution within
a process. A single process can
contain multiple threads running
concurrently.
Process vs Thread
The primary difference is that
threads within the same process run
in a shared memory space, while
processes run in separate memory
spaces.
Threads share their code section,
data section, and OS resources (like
open files and signals) with other
threads in the same process.
Thread Components
Like a process, each thread has its
own program counter (PC), register
set, and stack space, allowing
independent execution.
Page 3
T h r e a d s
What is a Thread?
Thread Definition
A thread is a path of execution within
a process. A single process can
contain multiple threads running
concurrently.
Process vs Thread
The primary difference is that
threads within the same process run
in a shared memory space, while
processes run in separate memory
spaces.
Threads share their code section,
data section, and OS resources (like
open files and signals) with other
threads in the same process.
Thread Components
Like a process, each thread has its
own program counter (PC), register
set, and stack space, allowing
independent execution.
Advantages of Threads
over Processes
Responsiveness
If a process is divided into
multiple threads, output from
completed threads can be
immediately returned, improving
application responsiveness.
Faster Context
Switch
Context switch time between
threads is lower compared to
process context switching, which
requires more CPU overhead.
Effective
Multiprocessor
Utilization
Multiple threads within a single
process can be scheduled across
multiple processors, making
execution faster.
Resource Sharing &
Communication
Resources like code, data, and
files can be shared among all
threads within a process.
Communication between threads
is easier due to shared address
space.
Page 4
T h r e a d s
What is a Thread?
Thread Definition
A thread is a path of execution within
a process. A single process can
contain multiple threads running
concurrently.
Process vs Thread
The primary difference is that
threads within the same process run
in a shared memory space, while
processes run in separate memory
spaces.
Threads share their code section,
data section, and OS resources (like
open files and signals) with other
threads in the same process.
Thread Components
Like a process, each thread has its
own program counter (PC), register
set, and stack space, allowing
independent execution.
Advantages of Threads
over Processes
Responsiveness
If a process is divided into
multiple threads, output from
completed threads can be
immediately returned, improving
application responsiveness.
Faster Context
Switch
Context switch time between
threads is lower compared to
process context switching, which
requires more CPU overhead.
Effective
Multiprocessor
Utilization
Multiple threads within a single
process can be scheduled across
multiple processors, making
execution faster.
Resource Sharing &
Communication
Resources like code, data, and
files can be shared among all
threads within a process.
Communication between threads
is easier due to shared address
space.
Thread Characteristics
Sequential
Execution with
Parallel Illusion
Threads are executed one after
another but give the illusion of
parallel execution through rapid
context switching.
Thread
Components
Program counter
Register set
Stack space
Interdependence
Threads are not independent of
each other as they share code,
data, and OS resources within the
same process.
State Changes
Each thread has different states
(running, ready, blocked) that it
transitions between during
execution.
Page 5
T h r e a d s
What is a Thread?
Thread Definition
A thread is a path of execution within
a process. A single process can
contain multiple threads running
concurrently.
Process vs Thread
The primary difference is that
threads within the same process run
in a shared memory space, while
processes run in separate memory
spaces.
Threads share their code section,
data section, and OS resources (like
open files and signals) with other
threads in the same process.
Thread Components
Like a process, each thread has its
own program counter (PC), register
set, and stack space, allowing
independent execution.
Advantages of Threads
over Processes
Responsiveness
If a process is divided into
multiple threads, output from
completed threads can be
immediately returned, improving
application responsiveness.
Faster Context
Switch
Context switch time between
threads is lower compared to
process context switching, which
requires more CPU overhead.
Effective
Multiprocessor
Utilization
Multiple threads within a single
process can be scheduled across
multiple processors, making
execution faster.
Resource Sharing &
Communication
Resources like code, data, and
files can be shared among all
threads within a process.
Communication between threads
is easier due to shared address
space.
Thread Characteristics
Sequential
Execution with
Parallel Illusion
Threads are executed one after
another but give the illusion of
parallel execution through rapid
context switching.
Thread
Components
Program counter
Register set
Stack space
Interdependence
Threads are not independent of
each other as they share code,
data, and OS resources within the
same process.
State Changes
Each thread has different states
(running, ready, blocked) that it
transitions between during
execution.
Threads vs Processes: Similarities
and Differences
Similarities
Only one thread or process
is active at a time
Within a process, both
execute sequentially
Both can create children
Differences
Threads are not
independent, processes are
Threads are designed to
assist each other
Processes may or may not
assist each other
Resource
Management
Processes have separate
memory spaces
Threads share memory
within a process
Threads have individual
stacks and registers
Read More