Systems study
Offline — showing the cached copy.
Home / Operating Systems / 2. Processes and threads

2. Processes and threads

One-liner. A process owns an address space; threads share it and own only a stack and registers.

Memorize

  • Process = address space + file descriptors + credentials + signal handlers + threads.
  • Thread = register state + stack + TLS; shares heap, code, fds with siblings.
  • Linux schedules tasks; a thread is a task with CLONE_THREAD, so processes and threads are the same primitive.
  • fork() copies page tables with copy-on-write; execve() replaces the image.
  • States: R running/runnable, S interruptible sleep, D uninterruptible (I/O), Z zombie, T stopped.
  • Context switch = save/restore registers + switch address space (CR3) + TLB effects.
  • Threads are cheaper to create and switch than processes, but a crash or leak is shared.
PROCESS ANATOMY ADDRESS SPACE code data heap mmap stacks KERNEL STATE fds creds signals namespaces cgroups THREADS registers + sta… SCHEDULER task_struct state priority CPU affinity
Process anatomy

Trap. Assuming D state is killable — uninterruptible sleep ignores signals until the I/O completes. Do this. Investigate the device/FS behind D-state tasks instead of escalating signals.

Check

What is shared between two threads of the same process?