What information does the OS keep about each process (the PCB / task_struct)?
Short answer: The OS keeps a process control block for every process; in Linux this is struct task_struct. It holds three kinds of information: identity (PID, parent, user and group IDs), saved execution context (registers, stack pointer, program counter, memory map) so the process can be resumed after a context switch, and scheduling and accounting data (state, priority, policy, CPU time used, statistics), plus pointers to resources (open files, signal handlers).
| Category | Examples (Linux task_struct fields) |
|---|---|
| Identity | pid, tgid (process ID shared by threads), real_parent, cred (UID/GID, capabilities), comm (name) |
| Saved context | thread (saved registers: SP, PC, callee-saved regs, FP/SIMD state), stack (kernel stack pointer), mm (address space / page tables) |
| Scheduling control | __state (older: state), prio, static_prio, rt_priority, policy, se (CFS/EEVDF entity with vruntime), cpus_mask (affinity) |
| Resources | files (open file table), fs (cwd, root), signal, sighand, nsproxy (namespaces), cgroups |
| Accounting/statistics | utime, stime, nvcsw/nivcsw (context switches), min_flt/maj_flt (page faults) |
Classifying fields (a typical exam question)
rt_priority→ scheduling control.pid→ identity.state→ scheduling control (the scheduler only runsTASK_RUNNINGtasks).files→ a resource (sometimes grouped with identity/context in textbooks).stack→ saved context (where the kernel stack and saved registers are).maj_flt→ accounting/statistics (major page faults).
Where to see it from user space: /proc/<pid>/status, /proc/<pid>/stat, /proc/<pid>/sched, /proc/<pid>/maps, and tools such as ps, top, pidstat.
RTOS comparison: a FreeRTOS task has a much smaller TCB (TCB_t): the saved stack pointer (registers are on the task's own stack), priority, state list links, stack bounds, name and notification values. There is no address space or file table, because all tasks share one memory space.