
Process vs Threads are given below:
Process
A process is an instance of a program in execution. A program becomes a process when an executable file is loaded in the main memory. A process is defined as an entity that represents the basic unit of work to be implemented in the system. Each process has its own address space and process control block (PCB).
Threads
A thread is the smallest unit of programmed instructions that can be managed independently and processing that can be performed by an operating system. A thread is also called a lightweight process. Multiple threads can be existing within the same process that shares common resources such as memory. If a process has multiple threads of control, it can perform more than one task at a time. Threads within a process share the same virtual memory space but each has a separate stack, and possibly “thread-local storage” if implemented. They are lightweight because a context switch is simply a case of switching the stack pointer and program counter and restoring other registers, whereas a process context switch involves switching the MMU context as well.
Process vs Threads
|
Process | Thread |
Definition
|
An executing instance of a program is called a process.
|
A thread is a subset of the process. |
Process
|
It has its own copy of the data segment of the parent process.
|
It has direct access to the data segment of its process. |
Communication
|
Processes must use inter-process communication to communicate with sibling processes.
|
Threads can directly communicate with other threads of its process. |
Overheads | Processes have considerable overhead. | Threads have almost no overhead. |
Creation | New processes require duplication of the parent process. | New threads are easily created. |
Changes | Any change in the parent process does not affect child processes. | Any change in the main thread may affect the behavior of the other threads of the process. |
Memory | Run in separate memory spaces. | Run in shared memory spaces. |
Dependence | Processes are independent. | Threads are dependent. |
You may also like: Multi-threading Models
Leave a Reply