Process Vs Thread: Explanation and Differences
In this article, we will discuss the difference between process and thread.
Process
A process is a program in execution. In other words, we can say that a process is a program that is pushed out from the ready state to the execution state in the CPU so that it can execute. The PCB (process control block) is responsible for keeping the track of the processes. A process can create new processes and the newly created process is known as child process. A process consume more time to finally get terminat and it doesn’t share any memory with other processes.
A process has the following states:
Start
This is the very first state when a process just begins.
Ready
The process that waits is assigned to the processor. The ready process waits to have the process allocated to them by the OS in order to run.
Running
When the process assigned to the processor by the OS scheduler, the process state is assigned to running and the processor starts executing the instructions.
Waiting
The process is transferred to the waiting state if it requires to wait for a resource, like waiting for the file in order to become available.
Terminated
When the process terminates the execution, or gets terminated by the operating system, then it get transferred to the terminated state where it waits for sometime to get removed from the main memory.
Thread
A thread is a section of a process and a process may contain many threads and these threads lies withing the process. A thread has the following states:
- Running
- Ready
- Blocked
The time takes by a thread is less as compared to a process. But a thread differs from a process in terms of memory sharing. A thread shares do share memory with other thread.
Differences
Some of the differences between a process and thread are the following:
Process | Thread |
The time to taken to create a process is less as compared to a thread. | A thread generally takes less time to create. |
Process is a program into execution. | Thread represents a section of process. |
A process remains isolated. | Thread shares memory. |
A process takes alot of time for context switching. | A thread takes lesser time for context switching. |
If one process is blocked then other process remains unaffected. | If a user-level thread is blocked then all other threads remain unaffected. |
A process is considered as heavyweight entity. | A thread is considered as lightweight entity. |
There is involvement of the system call. | No involvement of system call as it is created using API’s. |
Conclusion
In this article, we discussed the underlying differences between process and thread. We believe that this article has surely been knowledgeable for you.