4). Threads –
·
A thread is single sequential flow of control within a process.
·
A thread is also called lightweight process is a basic unit of CPU
utilization.
·
A process may be single thread or multi-thread.
·
If all thread of a single process run simultaneously and perform
different task done this situation is called multi-threading.
Advantages of Thread
- Threads minimize the context switching time.
- Use of threads provides concurrency within a process.
- Efficient communication.
- It is more economical to create and context switch threads.
- Threads allow utilization of multiprocessor architectures to a greater scale and efficiency.
Difference between Process and Thread
S.N.
Process
Thread
1
Process is heavy weight or resource
intensive.
Thread is light weight, taking lesser
resources than a process.
2
Process switching needs interaction with
operating system.
Thread switching does not need to interact
with operating system.
3
In multiple processing environments, each
process executes the same code but has its own memory and file resources.
All threads can share same set of open
files, child processes.
4
If one process is blocked, then no other
process can execute until the first process is unblocked.
While one thread is blocked and waiting, a
second thread in the same task can run.
5
Multiple processes without using threads use
more resources.
Multiple threaded processes use fewer
resources.
6
In multiple processes each process operates
independently of the others.
One thread can read, write or change another
thread's data.
S.N.
Process
Thread
1
Process is heavy weight or resource
intensive.
Thread is light weight, taking lesser
resources than a process.
2
Process switching needs interaction with
operating system.
Thread switching does not need to interact
with operating system.
3
In multiple processing environments, each
process executes the same code but has its own memory and file resources.
All threads can share same set of open
files, child processes.
4
If one process is blocked, then no other
process can execute until the first process is unblocked.
While one thread is blocked and waiting, a
second thread in the same task can run.
5
Multiple processes without using threads use
more resources.
Multiple threaded processes use fewer
resources.
6
In multiple processes each process operates
independently of the others.
One thread can read, write or change another
thread's data.