What resources are used when a thread created? How do the differ from those when a process is created?

4 years ago
Operating System

Because a thread is smaller than a process, thread creation typically uses fewer resources than process creation. Creating a process requires allocating a process control block (PCB), a rather large data structure. The PCB includes a memory map, list of open files, and environment variables. Allocating and managing the memory map is typically the most time-consuming activity. Creating either a user or kernel thread involves allocating a small data structure to hold a register set, stack, and priority.

  • Thread is a part of the process and it is called a lightweight process.
  • A process must have at least one thread. Therefore, creating a process means creating the process and creating a thread.
  • Since a thread is a part of the process, no additional resources are used when a thread is created, instead, it shares the memory space of the process from which this particular thread has been created.
  • Creation of a thread is cheap. Hence, it is called a lightweight process.
  • Whereas process creation is quite expensive because it has to set up a completely new virtual memory space for the process with its own address space.
  • Process creation takes a lot of CPU time and is called a heavyweight process.

Therefore, no resource is used when a thread is created whereas a new memory space is created while creating a process.

When a thread is created the threads does not require any new resources to execute the thread shares the resources like memory of the process to which they belong to. The benefit of code sharing is that it allows an application to have several different threads of activity all within the same address space. Whereas if a new process creation is very heavyweight because it always requires new address space to be created and even if they share the memory then the inter process communication is expensive when compared to the communication between the threads.

More related questions

Questions Bank

View all Questions