Operating systems · foundation

Thread vs process

A process is an operating-system resource and protection context with an address space; threads are execution flows within a process that typically share that address space and many process resources.

Why it matters

The boundary determines isolation, communication cost, failure containment, and which memory accesses require synchronization.

Mental model

How to reason about thread vs process

A process owns a room of resources. Threads are workers moving through the same room: each has its own instruction position and stack, but they can reach shared objects in the room.

Analogy

Separate workshops isolate tools and accidents but exchange materials through deliveries. Workers inside one workshop communicate cheaply but can interfere with the same equipment.

Examples

See the boundary, not just the happy path

Worked example · Shared heap

two native threads mutate the same in-process cache

Because the cache is in shared address space, the threads need synchronization around compound invariants.

Worked example · Process isolation

a worker process crashes while the supervisor remains alive

Separate address spaces improve containment, although the operating system and application determine how failures propagate.

Useful contrast · Runtime tasks

an async task or green thread

A language runtime may schedule many logical tasks on fewer OS threads; API names do not by themselves reveal the kernel execution unit.

Common mistakes

Misconceptions to remove early

Saying threads share everything

Threads normally have separate stacks, register state, and scheduling identity even though they share the process address space and resources.

Assuming processes cannot share memory

Shared-memory mappings and other IPC mechanisms can intentionally connect processes. The difference is that sharing is explicit rather than the default heap model.

Quick check

Can you predict the result?

1. Which resource do threads in one conventional process normally share?
  • The process address space
  • A single call stack
  • The same instruction pointer at all times
Answer: The process address space
2. What major benefit can a process boundary provide over another thread?
Answer: Stronger isolation and failure containment through a separate address-space and resource context.

Keep building

Authoritative references

Make the idea retrievable.

Study this concept with spaced repetition, next to the commands where you use it.

Get Terminaster