Skip to content

Try “polymorphism”, “TCP handshake” or “git rebase”.

    Computer Basics / Operating Systems

    Quick Reference

    Glossary and cheat sheet for Operating Systems — the page to reread before an interview.

    Extra: Reference9 min read

    Glossary#

    TermPlain meaningChapter
    operating system (OS)software that manages hardware and shares it between programs1
    kernelthe protected core of the OS, with full hardware access1
    user spacewhere normal programs run, without direct hardware access1
    device driverkernel code that knows how to talk to one kind of device1
    user mode / kernel modeCPU modes: restricted / everything allowed2
    system call (syscall)a program's request to the kernel (open, read, write…)2
    segmentation faultthe process touched memory it doesn't own and was killed2, 5
    processa running program with its own memory, files and PID3
    PIDprocess ID number3
    process control blockthe kernel's record of a process3
    fork / execcopy the current process / replace its program3
    schedulerkernel part that picks which thread runs on each core4
    time slicehow long a thread runs before the scheduler may switch4
    context switchsaving one thread's CPU state and loading another's4
    preemptionthe kernel taking the CPU away when a time slice ends4
    concurrency / parallelismtasks overlapping in time / literally at the same instant4
    CPU-bound / I/O-boundlimited by calculation / by waiting for disk or network4
    virtual / physical addressa process's private address / the real RAM position5
    page / framefixed-size chunk of virtual memory / of physical RAM5
    page table / MMU / TLBthe address map / hardware that uses it / its cache5
    page faulttouching a page not currently mapped in RAM5
    swap / thrashingdisk space used as extra RAM / constant swapping that makes everything slow5
    OOM killerLinux feature that kills a process when memory runs out5
    copy-on-writeshare pages after fork; copy only when one side writes5
    RSSmemory actually in RAM for a process5
    stack / stack frameper-thread memory for function calls / one call's slot6
    heapshared memory for objects and long-lived data6
    garbage collector (GC)automatically frees heap data nothing refers to6
    stack overflowrecursion too deep for the stack6
    memory leakmemory that's no longer needed but never freed6
    threadan independent sequence of instructions inside a process7
    race conditiona result that depends on thread timing8
    critical sectioncode touching shared data that must run one-at-a-time8
    lock / mutexlets only one thread into a critical section8
    atomichappens as one indivisible step8
    deadlockthreads waiting on each other's locks forever9
    livelock / starvationbusy but no progress / one thread never gets a turn9
    file systemorganises disk blocks into files and directories10
    block / inodea fixed-size disk chunk / a file's metadata record10
    path (absolute / relative)file's address from / / from the current folder10
    file descriptorsmall number a process uses for an open file or connection10
    stdin / stdout / stderrdescriptors 0 / 1 / 210
    page cacheRAM copy of file data; where writes land first10
    fsyncforce written data onto the physical disk10
    I/Oreading/writing disk, network, devices11
    blocking / non-blocking I/Osleep until ready / return immediately11
    epoll / kqueueLinux / macOS "tell me which connections are ready"11
    event loopone thread that waits for events and handles each in turn11
    signalsmall notification sent to a process (SIGTERM, SIGKILL…)12
    exit codenumber a process returns: 0 success, 128+N killed by signal N12
    graceful shutdownfinish in-progress work after SIGTERM, then exit12
    zombie / orphanexited but not collected / parent died first12

    Cheat Sheet#

    Process vs thread

    Output
      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

    Output
      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

    Output
      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 s

    Memory facts

    Output
      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)

    Output
      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#

    1. Watch a race condition. Save the Race.java program from Chapter 8 and run it with java Race.java three times. Then change count++ to be inside synchronized (Race.class) { ... } and confirm it always prints 2,000,000. Notice how much slower the locked version is.

    2. Find your processes. Run ps -o pid,ppid,command -p $$, note your shell's parent PID, then run ps -p <that ppid> to see what started your shell. Keep following parents until you reach PID 1.

    3. Signals by hand. In one terminal run sleep 1000. In another, find its PID with pgrep sleep, then kill -TERM <pid>. Back in the first terminal, run echo $? — you'll see 143 (128 + 15).