122

A process is a program in execution, with its own memory space. A thread is the smallest unit of execution inside a process; threads of the same process share its memory.

ProcessThread
HeavyweightLightweight
Own memory (code, data, heap, stack)Shares code, data and heap; has its own stack and registers
Context switch is slowContext switch is fast
Communicate via IPC (pipes, sockets, shared memory)Communicate directly through shared memory
One crashing does not affect othersOne crashing thread can crash the whole process

PCB (Process Control Block) stores everything about a process: PID, state, program counter, registers, memory info, open files, priority.

Context switch: saving the state of the running process in its PCB and loading the next one.