Threads versus processes
In Linux, a process is an instance of a program in execution. A process can have one or more threads of execution. A thread is a sequence of instructions that can proceed independently of other threads within the same process.
Each process has its own memory space, system resources, and execution context. Processes are isolated from each other and do not share memory by default. They can only communicate through files and inter-process communication (IPC) mechanisms, such as pipes, queues, sockets, shared memory, and so on.
A thread, on the other hand, is a lightweight unit of execution within a process. The overhead of loading the instructions from non-volatile memory to RAM or even the cache is already paid for by the process creating the thread – the parent process. Each thread has its own stack and register values but shares the memory space and system resources of the parent process. Because threads share memory within the process, they can...