# Editable study diagrams

120 SVG diagrams covering chapters 1-12 of `notes.txt`.

Open [the illustrated index](index.html) to browse, search, or filter by chapter.
Each SVG opens directly in Inkscape. Text is editable text, objects are ordinary
vector shapes, and related shapes are grouped. Four named layers separate the
page, connectors, objects, and annotations. There are no embedded raster images, linked assets, scripts, or web-font
dependencies in the SVGs.

The diagrams use black, white, and gray and the DejaVu Sans / Sans Mono font
families. Section references appear in each diagram's footer and metadata.
Examples use explicitly stated assumptions; memory layouts and execution traces
are schematic unless a concrete size or architecture is named.

The existing diagrams and source notes are unchanged. This collection adds
visual explanations; it is not a diagram for every paragraph of the book.

[Download the whole collection](editable-diagrams.zip), including this index.

## Editing and rebuilding

Open an individual `.svg` in Inkscape to edit its labels, shapes and connectors.
The layers and grouped objects remain independent. Arrow paths are editable;
they are not automatically rerouted when a node is moved.

Reproducible Python authoring sources are in `../tools/`. They use Python, Pillow,
and installed DejaVu fonts. Rendering and extent checks use the Inkscape CLI.
Rerunning a generator overwrites its generated SVG files, so keep manually
edited versions under new names if you also want to use the generators.

From the `lessif/` directory:

```sh
python3 note-diagrams/tools/build_01_03.py
python3 note-diagrams/tools/build_04_06.py
python3 note-diagrams/tools/build_07_08.py
python3 note-diagrams/tools/build_09_12.py
python3 note-diagrams/tools/build_catalog.py
python3 note-diagrams/tools/validate.py
```

## Contents

### 1. Foundations (10 diagrams)

- [One address, one selected memory location](01-addressed-memory-transfer.svg) -- notes 1.1.2.
- [A binary numeral is a weighted sum](01-binary-place-values.svg) -- notes 1.3.2.
- [Byte order changes placement, not the value](01-byte-order.svg) -- notes 1.4.2.
- [Where translation and execution happen](01-compiler-interpreter.svg) -- notes 1.4.7.
- [Two paths, one directory-tree destination](01-directory-paths.svg) -- notes 1.2.5.
- [The instruction pointer controls the next step](01-instruction-pointer-cycle.svg) -- notes 1.1.3.
- [Permission bits form three octal digits](01-permission-bit-groups.svg) -- notes 1.2.13.
- [From command text to argument strings](01-shell-word-expansion.svg) -- notes 1.2.6, 1.2.7.
- [Standard streams are independent routes](01-standard-stream-routing.svg) -- notes 1.2.11.
- [The same bits have two interpretations](01-twos-complement-wheel.svg) -- notes 1.4.2.

### 2. Pascal and data structures (10 diagrams)

- [Index an array; name a record field](02-array-record-storage.svg) -- notes 2.6.4, 2.6.5.
- [Assignment replaces a stored value](02-assignment-swap.svg) -- notes 2.2.2, 2.2.8.
- [Search chooses one subtree at each comparison](02-binary-search-tree.svg) -- notes 2.11.5.
- [Hanoi splits one task into three tasks](02-hanoi-decomposition.svg) -- notes 2.11.2.
- [A pointer to the incoming link unifies deletion](02-incoming-link-deletion.svg) -- notes 2.10.6.
- [Prepend without losing the old list](02-list-prepend.svg) -- notes 2.10.4.
- [Test before the body or after it](02-precondition-postcondition.svg) -- notes 2.2.10, 2.2.11.
- [Recursive calls postpone work until return](02-recursive-digit-output.svg) -- notes 2.3.7.
- [One arrival sequence, two removal orders](02-stack-queue-order.svg) -- notes 2.10.5.
- [Copy a value or name the caller storage](02-value-reference-parameters.svg) -- notes 2.3.4.

### 3. Assembly (10 diagrams)

- [Multiply widens; divide splits the result](03-double-width-arithmetic.svg) -- notes 3.2.8.
- [Effective address combines three terms](03-effective-address.svg) -- notes 3.2.5.
- [Macro expansion happens before program execution](03-macro-expansion-time.svg) -- notes 3.5.1, 3.5.2.
- [Copy backward when the destination overlaps above](03-overlapping-string-copy.svg) -- notes 3.2.13.
- [Register names overlap the same bits](03-register-aliases.svg) -- notes 3.2.1.
- [The comparison is the same; the chosen flags differ](03-signed-unsigned-flags.svg) -- notes 3.2.7, 3.2.9.
- [EBP anchors one invocation while ESP moves](03-stack-frame-offsets.svg) -- notes 3.3.5, 3.3.6, 3.3.7.
- [An unresolved symbol pulls in an archive member](03-static-linker-symbols.svg) -- notes 3.7.5.
- [A syscall enters through an OS-defined gate](03-syscall-gate.svg) -- notes 3.6.4, 3.6.5.
- [x87 pushes change TOP, not every stored value](03-x87-logical-stack.svg) -- notes 3.8.2, 3.8.3.

### 4. C (10 diagrams)

- [Reallocation must preserve the original pointer](04-allocation-lifetime.svg) -- notes 4.3.14; 4.10.1.
- [Pointer arithmetic counts elements](04-array-stride.svg) -- notes 4.3.13; 4.9.1.
- [Inorder traversal: left, node, right](04-bst-inorder.svg) -- notes 4.5.4.
- [A callback combines reusable traversal with private state](04-callback-context.svg) -- notes 4.9.3.
- [Delete a node by changing its incoming link](04-list-incoming-link.svg) -- notes 4.5.2; 4.9.2.
- [A pointer to a literal is not a character array](04-literal-and-array.svg) -- notes 4.3.19.
- [Pointer assignment and value assignment](04-pointer-aliases.svg) -- notes 4.3.11.
- [Declarations compile; definitions link](04-separate-compilation.svg) -- notes 4.7.1; 4.7.2; 4.7.3.
- [A C string ends at its first zero byte](04-string-boundaries.svg) -- notes 4.3.18.
- [Structure layout includes padding](04-structure-padding.svg) -- notes 4.5.1.

### 5. Operating-system services (10 diagrams)

- [File descriptors are references, not file positions](05-descriptor-sharing.svg) -- notes 5.2.3; 5.3.4.
- [Termination and reaping are separate events](05-exit-wait.svg) -- notes 5.3.6; 5.3.7.
- [fork creates a process; exec replaces its program](05-fork-exec.svg) -- notes 5.3.4; 5.3.5.
- [Mapped addresses provide another view of file bytes](05-mapped-file.svg) -- notes 5.2.7.
- [Names lead to inodes; open files can outlive names](05-names-and-inodes.svg) -- notes 5.2.1.
- [Read, write, execute: three bits per class](05-permission-bits.svg) -- notes 5.2.2.
- [Pipe EOF depends on every writer reference](05-pipe-reference-lifetime.svg) -- notes 5.3.15.
- [Redirection rewires a descriptor before exec](05-redirection.svg) -- notes 5.3.10.
- [Check and wait must be one atomic handoff](05-signal-wait-race.svg) -- notes 5.3.14.
- [A terminal targets its foreground process group](05-terminal-process-groups.svg) -- notes 5.4.2.

### 6. Networks (10 diagrams)

- [Datagrams preserve boundaries; streams preserve byte order](06-datagrams-streams.svg) -- notes 6.2.4; 6.3.3; 6.3.4.
- [DNS distributes authority through a name hierarchy](06-dns-delegation.svg) -- notes 6.2.6.
- [Each lower layer carries the unit above it](06-encapsulation.svg) -- notes 6.2.1; 6.2.3.
- [Network byte order is most significant byte first](06-network-byte-order.svg) -- notes 6.2.3; 6.3.2.
- [One server port supports many connected sockets](06-port-demultiplexing.svg) -- notes 6.2.4; 6.3.4.
- [The longest matching prefix selects the route](06-route-selection.svg) -- notes 6.1.2; 6.2.3.
- [Wait for readiness, then do bounded work](06-select-event-loop.svg) -- notes 6.4.3; 6.4.4.
- [A listener and its accepted sockets have different jobs](06-socket-lifecycles.svg) -- notes 6.3.4.
- [Frame complete lines before advancing the session](06-stream-framing-fsm.svg) -- notes 6.4.5.
- [Connection establishment exchanges sequence numbers](06-tcp-handshake.svg) -- notes 6.2.4; 6.3.4.

### 7. Concurrency (12 diagrams)

- [Testing and claiming must be one operation](07-atomic-claim.svg) -- notes 7.1.3; 7.1.5.
- [A haircut needs both admission and completion signals](07-barber-rendezvous.svg) -- notes 7.2.5.
- [Reserve the buffer resource before taking its mutex](07-buffer-wait-before-lock.svg) -- notes 7.2.1.
- [Lock the whole invariant](07-critical-section-boundaries.svg) -- notes 7.1.2.
- [File-lock lifetime follows its ownership model](07-file-lock-ownership.svg) -- notes 7.4.3; 7.4.4; 7.4.5.
- [A read-only scan can still race](07-inconsistent-snapshot.svg) -- notes 7.1.1.
- [Two increments, one lost update](07-lost-update.svg) -- notes 7.1.1.
- [Peterson: the last contender yields](07-peterson-tie-break.svg) -- notes 7.1.3.
- [A full pipe can turn wait-before-read into deadlock](07-pipe-wait-deadlock.svg) -- notes 7.2.2.
- [Reader overlap can keep a writer waiting](07-reader-cohort-gate.svg) -- notes 7.2.4.
- [A global lock order breaks circular wait](07-resource-order-cycle.svg) -- notes 7.2.2; 7.2.3.
- [A semaphore counts unclaimed permits](07-semaphore-permits.svg) -- notes 7.1.6.

### 8. Inside the kernel (12 diagrams)

- [A buffer can combine writes and satisfy reads](08-buffer-write-coalescing.svg) -- notes 8.4.6.
- [A context switch changes which saved state runs](08-context-switch.svg) -- notes 8.2.1; 8.3.3.
- [A recoverable page fault restarts the instruction](08-demand-page-restart.svg) -- notes 8.3.2; 8.3.5.
- [Virtual contiguity does not imply physical contiguity](08-dma-scattered-pages.svg) -- notes 8.4.10; 8.3.5.
- [Three causes of entry into the kernel](08-kernel-entry-causes.svg) -- notes 8.1; 8.1.1.
- [Paging uses scattered free frames](08-paging-fragmentation.svg) -- notes 8.3.1; 8.3.3; 8.3.5.
- [Interrupts allow useful CPU work while a device runs](08-polling-interrupt-overlap.svg) -- notes 8.4.5.
- [I/O completion makes a task ready, not immediately running](08-ready-is-not-running.svg) -- notes 8.2.1; 8.2.2; 8.4.5.
- [Shared storage can split on a private write](08-shared-page-copy.svg) -- notes 8.3.1; 8.3.5.
- [Signal delivery temporarily redirects user execution](08-signal-frame-return.svg) -- notes 8.2.3.
- [A TLB caches translations, not program data](08-tlb-translation.svg) -- notes 8.3.5.
- [One path can cross into another filesystem](08-vfs-mount-lookup.svg) -- notes 8.4.8.

### 9. Programming paradigms (6 diagrams)

- [A callback separates registration from invocation](09-callback-registration.svg) -- notes 9.4.1.
- [Metaprogramming has two separate executions](09-code-generation.svg) -- notes 9.4.3.
- [A fold chooses the nesting of operations](09-fold-direction.svg) -- notes 9.2.3.
- [Explicit state turns chunks into complete lines](09-line-parser-state.svg) -- notes 9.4.2; 10.10.
- [A tail call leaves no work for its caller](09-tail-call-frames.svg) -- notes 9.2.4.
- [Recursion remembers the route through a tree](09-tree-traversal.svg) -- notes 9.2.1.

### 10. C++ and object lifetimes (12 diagrams)

- [An abstract data type protects a representation invariant](10-adt-invariant.svg) -- notes 10.3.4; 10.8.2.
- [One event selector dispatches many client sessions](10-chat-event-selector.svg) -- notes 10.10.
- [Construction order also defines destruction order](10-construction-order.svg) -- notes 10.4.15; 10.6.4.
- [Initialization and assignment start from different states](10-copy-or-assignment.svg) -- notes 10.4.10; 10.4.18.
- [Stack unwinding releases fully constructed local owners](10-exception-unwinding.svg) -- notes 10.5.3; 10.5.7.
- [Copying into a base value discards the derived part](10-object-slicing.svg) -- notes 10.6.2; 10.6.10.
- [Copying a pointer is not copying its owned storage](10-owning-pointer-copy.svg) -- notes 10.4.10; 10.4.18; 10.4.19.
- [A proxy separates reading a cell from writing it](10-sparse-array-proxy.svg) -- notes 10.4.25.
- [One template produces type-specific operations](10-template-instantiation.svg) -- notes 10.7.1; 10.7.2; 10.7.3.
- [A member call passes an object as well as arguments](10-this-pointer.svg) -- notes 10.3.1; 10.3.2.
- [A virtual call follows the actual object type](10-virtual-dispatch.svg) -- notes 10.6.5; 10.6.6.
- [A callback adapter restores object-specific behavior](10-widget-callback-adapter.svg) -- notes 10.11.2; 10.11.10.

### 11. Functional and logic programming (12 diagrams)

- [A closure keeps the environment of its creation](11-closure-environment.svg) -- notes 11.1.9; 11.1.10.
- [Two lists can share a tail without copying it](11-cons-sharing.svg) -- notes 11.1.3; 11.1.6.
- [A continuation represents the rest of a computation](11-continuation.svg) -- notes 11.2.4; 11.2.5.
- [Currying replaces a tuple input with a returned function](11-currying.svg) -- notes 11.5.14.
- [The same list can be program structure or data](11-eval-and-quote.svg) -- notes 11.1.4; 11.1.7.
- [A fixed point ties a recursive function back to its body](11-fixed-point.svg) -- notes 11.5.15.
- [A finite demand can use an infinite structure](11-infinite-prefix.svg) -- notes 11.5.12; 11.5.13.
- [Lazy evaluation delays work and shares its result](11-lazy-sharing.svg) -- notes 11.5.1.
- [Map preserves the shape; fold summarizes the sequence](11-map-and-fold.svg) -- notes 11.1.11; 11.5.11.
- [Backtracking explores alternatives and undoes bindings](11-prolog-backtracking.svg) -- notes 11.4.5; 11.4.6.
- [One relation can be queried in several directions](11-relations-and-modes.svg) -- notes 11.4.7.
- [Unification finds a consistent substitution](11-unification.svg) -- notes 11.4.3; 11.4.4.

### 12. Tcl and execution strategies (6 diagrams)

- [Embedding creates a two-way boundary between C and Tcl](12-embedded-interpreter.svg) -- notes 12.3.1; 12.3.2.
- [Execution strategies differ in which representations run](12-execution-strategies.svg) -- notes 12.5.3.
- [Self-contained delivery is a boundary around dependencies](12-runtime-dependencies.svg) -- notes 12.5.5; 12.5.7.
- [Braces delay substitution until the receiving command acts](12-tcl-braces.svg) -- notes 12.2.3.
- [Tcl groups words before ordinary substitution](12-tcl-word-formation.svg) -- notes 12.2.1; 12.2.2; 12.2.3.
- [Widget names express containment; a manager controls layout](12-tk-widget-tree.svg) -- notes 12.4.3; 12.4.4.
