Some of the important properties of threads are:
- Lighter than a process
- Faster to create
- Context switching is less overhead
- Data sharing is easier
- Increases the responsiveness
Lightweight than process:
- Thread is said to be lightweight than a process in terms of resource consumption.
- Most of the resources of a thread are inherited from a process like complete memory space, signal table, page table.
- Each thread only has its own stack section that means its own local variable, a program counter(next instruction to be executed), registers.
- Thread is also called light weight process because of the above reason.
Creating a thread is faster than a process:
- Threads are faster or cheaper to create in comparison to process because they only need a stack and registers, the rest are copied directly from the process.
- Many tables need to initialize while process creation like Process Control Block(PCB), signal table, Page table whereas in the case of threads all these tables are directly inherited.
- Most of the work of creating a thread is done at user space, not at kernel space.
Switching between threads is faster than process:
- Context switching is faster in threads as they only need to save stack pointer, program counter and registers.
- But in the case of process, process state, the program counter(PC), the values of the different registers, the CPU scheduling information for the process, memory management information regarding the process, possible accounting information for this process, and I/O status information of the process have to save.
- Thus context switching is less overhead in the case of threads.
Data sharing within threads:
- Data sharing between threads can easily be done as they are not independent, share the same address space.
- All threads can read and modify a shared pool of memory easily.
They add more responsiveness to the system:
- They increase the responsiveness of the system in terms of parallelism.
- Each thread can be scheduled independently to perform different tasks simultaneously.
- Thread Introduction
- Types of Thread: User-Level and Kernel Threads
- Memory layout of Thread
- Thread Control Block(TCB)
- Pros and cons of a Thread
- Process Vs Thread
- Thread Programming
Categories: Operating system (OS)
Leave a Reply