Glossary#
| Term | Plain meaning | Chapter |
|---|---|---|
| operating system (OS) | software that manages hardware and shares it between programs | 1 |
| kernel | the protected core of the OS, with full hardware access | 1 |
| user space | where normal programs run, without direct hardware access | 1 |
| device driver | kernel code that knows how to talk to one kind of device | 1 |
| user mode / kernel mode | CPU modes: restricted / everything allowed | 2 |
| system call (syscall) | a program's request to the kernel (open, read, write…) | 2 |
| segmentation fault | the process touched memory it doesn't own and was killed | 2, 5 |
| process | a running program with its own memory, files and PID | 3 |
| PID | process ID number | 3 |
| process control block | the kernel's record of a process | 3 |
| fork / exec | copy the current process / replace its program | 3 |
| scheduler | kernel part that picks which thread runs on each core | 4 |
| time slice | how long a thread runs before the scheduler may switch | 4 |
| context switch | saving one thread's CPU state and loading another's | 4 |
| preemption | the kernel taking the CPU away when a time slice ends | 4 |
| concurrency / parallelism | tasks overlapping in time / literally at the same instant | 4 |
| CPU-bound / I/O-bound | limited by calculation / by waiting for disk or network | 4 |
| virtual / physical address | a process's private address / the real RAM position | 5 |
| page / frame | fixed-size chunk of virtual memory / of physical RAM | 5 |
| page table / MMU / TLB | the address map / hardware that uses it / its cache | 5 |
| page fault | touching a page not currently mapped in RAM | 5 |
| swap / thrashing | disk space used as extra RAM / constant swapping that makes everything slow | 5 |
| OOM killer | Linux feature that kills a process when memory runs out | 5 |
| copy-on-write | share pages after fork; copy only when one side writes | 5 |
| RSS | memory actually in RAM for a process | 5 |
| stack / stack frame | per-thread memory for function calls / one call's slot | 6 |
| heap | shared memory for objects and long-lived data | 6 |
| garbage collector (GC) | automatically frees heap data nothing refers to | 6 |
| stack overflow | recursion too deep for the stack | 6 |
| memory leak | memory that's no longer needed but never freed | 6 |
| thread | an independent sequence of instructions inside a process | 7 |
| race condition | a result that depends on thread timing | 8 |
| critical section | code touching shared data that must run one-at-a-time | 8 |
| lock / mutex | lets only one thread into a critical section | 8 |
| atomic | happens as one indivisible step | 8 |
| deadlock | threads waiting on each other's locks forever | 9 |
| livelock / starvation | busy but no progress / one thread never gets a turn | 9 |
| file system | organises disk blocks into files and directories | 10 |
| block / inode | a fixed-size disk chunk / a file's metadata record | 10 |
| path (absolute / relative) | file's address from / / from the current folder | 10 |
| file descriptor | small number a process uses for an open file or connection | 10 |
| stdin / stdout / stderr | descriptors 0 / 1 / 2 | 10 |
| page cache | RAM copy of file data; where writes land first | 10 |
| fsync | force written data onto the physical disk | 10 |
| I/O | reading/writing disk, network, devices | 11 |
| blocking / non-blocking I/O | sleep until ready / return immediately | 11 |
| epoll / kqueue | Linux / macOS "tell me which connections are ready" | 11 |
| event loop | one thread that waits for events and handles each in turn | 11 |
| signal | small notification sent to a process (SIGTERM, SIGKILL…) | 12 |
| exit code | number a process returns: 0 success, 128+N killed by signal N | 12 |
| graceful shutdown | finish in-progress work after SIGTERM, then exit | 12 |
| zombie / orphan | exited but not collected / parent died first | 12 |
Cheat Sheet#
Process vs thread
process private memory · isolated · heavier · talk via IPC (pipes, sockets, files)
thread shared heap · own stack · lighter · talk via shared variables (needs locks)Fixing shared-data bugs
race condition → lock (synchronized / mutex) · atomic (AtomicInteger) · don't share
deadlock → same lock order everywhere · timeouts · fewer locks
DB race → atomic UPDATE ... WHERE · row locks (03_Backend/02_Databases/07)Signals and exit codes
Ctrl+C = SIGINT (2) polite stop = SIGTERM (15) force = SIGKILL (9)
exit 0 = success 137 = killed by SIGKILL (often OOM) 143 = SIGTERM
docker stop grace = 10 s Kubernetes grace = 30 sMemory facts
page size: 4 KB (Linux x86-64) · 16 KB (Apple Silicon)
stack: small, per thread, fast · heap: large, shared, garbage collected
Python recursion limit: 1,000 · Java deep recursion → StackOverflowError
write() success ≠ on disk → fsync()Commands to look around (macOS / Linux)
ps aux list processes
top (or htop) live CPU/memory per process
kill -TERM <pid> ask a process to stop; kill -9 <pid> forces it
getconf PAGESIZE page size
ulimit -n max open files for this shell
sysctl -n hw.ncpu number of CPU cores (macOS) · nproc (Linux)
strace -f <command> watch system calls (Linux)Try This Yourself#
Watch a race condition. Save the
Race.javaprogram from Chapter 8 and run it withjava Race.javathree times. Then changecount++to be insidesynchronized (Race.class) { ... }and confirm it always prints 2,000,000. Notice how much slower the locked version is.Find your processes. Run
ps -o pid,ppid,command -p $$, note your shell's parent PID, then runps -p <that ppid>to see what started your shell. Keep following parents until you reach PID 1.Signals by hand. In one terminal run
sleep 1000. In another, find its PID withpgrep sleep, thenkill -TERM <pid>. Back in the first terminal, runecho $?— you'll see143(128 + 15).