Operating System
Operating System
Harshada Bhosale
ROLL NO: TI2121
THREAD
A thread is a flow of execution through the process code, with its own program counter, system
register and stacks. A thread is also called as a light weight process. Thread provides a way to
improve application performance through parallelism.
Each thread belongs to exactly one process and no thread can exists outside the process.
Difference between process and thread:
S.N Process Thread
Disadvantages :
i. Each user thread, the kernel thread is required.
ii. Creating a kernel thread is overhead.
iii. It reduces the performance of system.
2. Many to one thread :
The many-to-one model maps many user level threads to one kernel
thread. Thread management is done in user space, so it is efficient,
but the entire process will block if a thread makes a blocking system
call.
Advantages :
i. One kernel thread controls multiple user threads.
ii. It is efficient because thread management is done by thread library.
iii. Used in language systems, portable libraries.
Disadvantages :
i. The disadvantage is entire process will block if a thread makes blocking
system call.
ii. Multiple threads are not able to run in parallel since only one thread can
be accessed by kernel at a time.
3. Many to many thread :
In this model, many user level threads multiplex to the Kernel thread
of smaller or equal numbers.
The number of Kernel threads may be specific to either a particular
application or a particular machine.
Solaris 2, IRIX, HP-UX and Tru64 UNIX support many to many thread
model.
Advantages :
i. Many threads can be created as per user’s requirement.
ii. Provides the best accuracy on concurrency.
iii. When a thread performs a blocking system call, the kernel can
schedule another thread for execution.
iv. Multiple kernel or equal to user threads can be created.
Disadvantages:
i. Multiple threads of kernel are an overhead for OS.
ii. Low performance.
iii. True concurrency cannot be achieved.
Benefit of threads :
1. Resourse sharing
2. Responsivness
3. Proper utilization and multiprocessor artchitecture
4. Economical
5. Efficient communication
6. Computational speed up
Advantages of Thread :
1. Thread minimizes context switching time.
2. Use of threads provides concurrency within process.
3. Efficient communication.
4. It is more economical to create and context switch thread
5. Utilization of multiprocessor architecture to a greater scale and efficiency.
Disadvantages of Threads :
1. Blocking of parent thread will stop all the child thread.
2. Security.