A thread is the basic part of CPU utilization. It is also called a lightweight process. It is a series of instructions within a process. A thread behaves like a process within a process but it is does not have its own PCB( Process Control Box). Usually, multiple threads are created within a process. The multiple threads in a process enable multiple executions.
Thread consists of following:
- Thread ID
- Program counter
- Register Set
- Stack
A thread shares the following with its peer thread in a particular task:
- Code Section
- Data section
- Any operating system resources. Which are available to task.
Benefits of Threads:
- Threads can take advantage of multiprocessors.
- Threads share common data and do not need to use inter-process communication.
- Threads are easy to create as they only need a stack and storage for register.
- Context switching becomes fast when working with threads.
- Threads use very small resources of an operating system. They don't need new address space, global data, program code or operating system resources.
No comments:
Post a Comment