knaxuslearn · build · ship

Roadmaps / Fundamentals / Phase 2

Phase 2 of 4 · Study weeks 5-8

The operating system

This phase makes the second checkpoint possible: a server that stores data durably and where you can say what it asks of the kernel.

Topics every week

  1. Week 58 h
    • Processes and threads
    • System calls and their cost
    • Virtual memory and page faults
    • File descriptors and limits

    Hand inA system call trace of the server and a count per message

  2. Week 68 h
    • The file system and the page cache
    • write, fsync and what they promise
    • Short writes and errors
    • Atomic renames

    Hand inThe append log with a flush policy and a test for a short write

  3. Week 78 h
    • I/O models: blocking, non-blocking, epoll and io_uring
    • Scheduling and context switches
    • CPU and memory limits in containers

    Hand inA note comparing the I/O models with one measurement each

  4. Week 88 h
    • Observing a running process: strace, perf, /proc, iostat
    • Crash tests with kill -9
    • Predicted against measured

    Hand inCheckpoint 2: the three-policy table and the 20-kill table

Practice projects

  • Practice 1, the syscall count (Week 5): trace the server for 10,000 messages. Done when: you list the five most frequent system calls and the count per message.
  • Practice 2, the short write (Week 6): make the file system return fewer bytes than asked, with a test double. Done when: the log stays correct, and a test fails without your fix.
  • Practice 3, the crash (Week 8): kill the process in the middle of a batch, 20 times. Done when: every acknowledged message is present after restart and the table shows the result.
  • Optional, the I/O models: serve 1,000 connections with threads, then with epoll or the language's event loop. Done when: a table shows memory and latency for each.

GitHub repos to study

Existence and last commit were checked on 22 Nov 2026 by shallow clone. Every repository below had a commit in the last 12 months.

RepoWhat to readWeek
torvalds/linuxfs/read_write.c and the epoll implementation6
axboe/liburingThe io_uring examples and the man pages7
iovisor/bccTools such as biolatency and opensnoop and how they work8
opencontainers/runcHow cgroups and namespaces limit a process7

Milestone checkpoint

Build Checkpoint 2. Write the kill script and your throughput predictions first. Add the log, the three flush policies and the short-write test. Run the 20 kills for each policy and fill the table. Hand in the traces, the table, ADR-3 (the acknowledgement rule) and ADR-4 (the I/O model).

Check yourself

Answer each question in your head first, then open it to check.

  1. What does write return, and what does it not guarantee?
    It returns the number of bytes accepted, which can be fewer than asked. The data is in the operating system buffer, not on the disk.
  2. What does fsync guarantee, and what can still be lost?
    The data and metadata of that file are flushed to the device. A new file's directory entry needs its own sync, and a device that lies about flushing can still lose data.
  3. Why do system calls cost more than function calls?
    They cross into the kernel, which switches privilege level and may flush caches. Batching calls shares that fixed cost.
  4. What is a page fault, and when is it expensive?
    A page fault happens when a process touches memory that is not mapped yet. It is cheap if the page is in memory, and expensive if the kernel must read it from disk.
  5. When would you choose epoll over threads?
    When you have many mostly idle connections, so a thread each would use too much memory and too many context switches.