- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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
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 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.
|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.|
- Zombie vs Orphan vs Daemon Processes
- Zombie and Orphan Processes in Linux
- How to Find the List of Daemon Processes and Zombie Processes in Linux
- How to find and kill running processes in linux
- Count the number of threads in a process on linux
- What Linux utility for sorting processes by network usage?
- What is the maximum number of threads per process in Linux?
- How to Kill Linux Processes Using ‘xkill’ Command
- How to Count the Number of Threads in a Process on Linux
- How to find out which processes are using swap space in Linux?
- How to see top processes sorted by actual memory usage on Linux?
- User-level threads and Kernel-level threads
- Threads in C#
- Difference Between Daemon Threads and User Threads In Java
- Joining Threads in Java