
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Threads vs Processes in Linux
Process
A process is the execution of a program that allows you to perform the appropriate actions specified in a program. It can be defined as an execution unit where a program runs. The OS helps you to create, schedule, and terminate the processes which are used by the CPU. The other processes created by the main process are called child processes.
Thread
Thread is an execution unit that is part of a process. A process can have multiple threads, all executing at the same time. It is a unit of execution in concurrent programming.
Consider the table shown below that depicts the differences between a process and a thread on different bases.
Comparison Basis | Process | Thread |
---|---|---|
Definition | A process is a program under execution. | Thread is the Execution unit. |
Context switching time | Processes require more time for context switching as they are heavier. | Threads require less time for context switching as they are lighter than processes. |
Memory | Processes are totally independent and don’t share memory. | Threads share memory. |
Communication | Communication between processes requires more time than compared to threads. | Communication between threads requires less time compared to processes . |
Resource Consumption | Processes require more resources than threads. | Threads generally need less resources than processes. |
Dependency | Individual processes are independent of each other. | Threads are parts of a process and so are dependent. |
Data and Code sharing | Processes have independent data and code segments. | A thread shares the data segment, code segment, files etc. with its peer threads. |
Treatment by OS | All the different processes are treated separately by the OS. | All user level peer threads are treated as a single task by the OS. |
Time for creation | Processes require more time for creation. | Threads require less time for creation. |
Time for termination | Processes require more time for termination. | Threads require less time for termination. |
Advertisements