The Runtime Theory
Processes and Threads

Processes, Threads, and the Cost of Sharing

A process is a protected resource container with an address space and operating-system-managed resources.

The Runtime Theory Team5 min read#processes#threads#scheduling
▸ On this page

The model

A process is a protected resource container with an address space and operating-system-managed resources. A thread is an execution stream with its own program counter, registers, and stack. Threads in one process normally share code and heap memory, which makes communication cheap but coordination necessary.

A concrete walk-through

When a thread blocks on I/O, the scheduler may run another runnable thread. A context switch saves enough state to resume later and changes which execution stream receives CPU time. Creating a thread does not guarantee it runs immediately; scheduling policy, contention, and available cores influence when it progresses.

Costs and failure cases

Threads share mutable state, so unsynchronized access can produce races even on a single core through interleaving. Processes provide stronger isolation but require explicit communication and often more setup. More threads can increase context switching, memory use, and contention instead of increasing throughput.

Check your understanding

A server creates one thread per connection and suddenly slows down under a large idle-client load. Name two resource costs and one alternative concurrency model to evaluate.

Further reading

Operating Systems: Three Easy Pieces

Not started

Sign in to save your learning progress.

Sign in to save