Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 05 · How Computers Work · Talking to the kernel · about 18 min to read

Play it as a journeyTutor comes with a plan

The filing cabinet: how a file system is built

The Memory Hierarchy
The Memory Hierarchy · Open board

Storage in layers, each bigger and slower than the one above it. This lesson builds the bottom layers: the cabinet that holds files, and what it is made of.

Before you start. A file is bytes, a numbered record called an inode (its size, owner and where its bytes sit), and a name in a directory that points at that number. A save first lands in the page cache in RAM, and a journal is a notebook where the file system writes a change down before making it, so a crash leaves each change done or not done (The drawer that says it saved). A program never touches the disk. It asks the kernel, the one program with full access to the hardware, through a system call (Processes, Threads & the Kernel). The disk is slow and sits on the far side of a bus (I/O, Interrupts & the Bus). The program holds only a small number, a file descriptor, and uses the same open, read, write and close for everything (Everything is a file descriptor).

Lesson 26 of 41 in How Computers Work

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • December 1987: a hundred cheap disks, and one dead every twelve days
  • The VFS: one front desk for every kind of cabinet
  • Extents: one record that says “from here, this many blocks”
  • Copy-on-write: no notebook, because nothing is ever overwritten
  • RAID and parity: a drawer can break and the cabinet carries on
  • The layers, and what each one cannot do
  • The VFS objects
  • The extent, as printed
  • The journal’s cost, and the three modes
  • The copy-on-write toy
  • Parity on whole bytes
  • The levels, and the weak spots

Terms it explains: virtual file system, VFS, extent, copy-on-write, parity, RAID, superblock, inode, dentry, file, write hole, cache, cache line, DRAM, hit rate, hit/miss, latency vs bandwidth, LRU/associativity, memory wall, MMU/page table, NUMA, prefetch, spatial locality, SRAM, swap/paging, temporal locality, TLB, virtual memory, working set.

Lab

Same data, same O(n), four access patterns. Why is one of them 31 times slower?

Pick Following a chain of pointers, drag Memory the loop walks from end to end, and watch The bill jump.

Open The memory hierarchy

Related paper

Review How Computers Work