What resources are shared between threads of the same process, and what are kept private?
Last updated
Threads of one process share everything that belongs to the process as a whole (its address space and resources), but each keeps a private execution context so it can run independently. The rule of thumb: shared = process-wide state, private = per-thread execution state.
Shared across threads:
The code/text segment, heap, and global/static data.
Open file descriptors, signal handlers, and the process's address space (page tables).
Because memory is shared, access to shared data needs synchronization (locks, atomics).
Private per thread:
Its own stack (local variables, call frames).
Its own registers and program counter.
Thread-local storage (TLS) and typically its own errno.
Why this split: A private stack/registers lets each thread have an independent call path; shared memory lets them collaborate cheaply.