Operating System Interview Questions · Question 05

What is the difference between a process and a thread?

Interview preparation resource from Gate Smashers.

Interview-ready answer

A process is a protected resource container with its own address space, while a thread is an execution path inside that process. Threads share process resources but keep their own registers, program counter and stack.

Diagram for What is the difference between a process and a thread?
Understand it clearly

Processes provide isolation. A failure in one process normally does not corrupt another process because their virtual address spaces are separate. Communication between processes therefore needs an IPC mechanism.

Threads are lighter because threads in the same process share code, heap and open files. This makes communication fast, but it also creates synchronization problems: one faulty thread can corrupt shared data or crash the complete process.

A web server illustrates the trade-off well. Multiple threads can handle requests efficiently because they share cached data, but access to that data must be synchronized. Separate processes provide stronger isolation, although communication and context switching are generally more expensive.

Quick comparison
BasisProcessThread
RoleResource and protection containerExecution path
MemorySeparate address spaceShares process address space
Private stateComplete process stateRegisters, PC and stack
CostHeavier to create and switchLighter to create and switch