Difference Between Process and Threads

A program in execution is called a process. There can be multiple instances of a program running in the system which are identified by a unique id called process id. Operating System ensures that each process has a unique id which is always a non-negative integer number.

A thread is a lightweight process which can only be used inside a process. Like process, thread also has a unique identifier to identify threads which are called thread ids. Unlike process ids, thread ids are only unique to a process and one process threads are unknown to other process.

Process Vs Threads

ProcessThread
A program in execution is called process.Thread is a lightweight process which executes smaller portion of a process.
Process takes more time to create and terminate.Thread takes lesser time to create and terminate.
Each process has its own time slot to run scheduled by the Operating system. Hence context switching is slower.All threads share the same time slot of its parent process. Hence context switching is faster.
Process has its own control block, stacks, heaps.Thread has its own control block and stack but shares parent process heaps etc.
Inter process communication required to interact between processes.Since thread shares the same address space of parent processes, hence no extra method is required to share information.
Process can be created using fork () method.Thread can be created using pthread_create () method.

Leave a Reply

Your email address will not be published. Required fields are marked *