Friday, April 12, 2019

What are threads? Give benefits of threads.

Threads:

 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:
  1. Threads can take advantage of multiprocessors.
  2. Threads share common data and do not need to use inter-process communication.
  3. Threads are easy to create as they only need a stack and storage for register.
  4. Context switching becomes fast when working with threads.
  5. 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