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 · with code: Go · about 17 min to read

Play it as a journeyTutor comes with a plan

Everything is a file descriptor

IO Interrupts and the Bus
IO Interrupts and the Bus · Open board

A disk, a keyboard and a network card, each answered with the same few words by the operating system. This lesson is about the small number a program holds in its hand when it talks to any of them.

Before you start. A process is one running program with a wall around it, and the only way through the wall is a system call, a request to the kernel, the part of the operating system that owns the hardware (Processes, Threads & the Kernel). Above every device the kernel offers the same four calls: open (ask for a thing), read (take bytes from it), write (give it bytes) and close (hand it back), so that a program need not care what is on the other side (I/O, Interrupts & the Bus).

Lesson 25 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

  • 1972: a blackboard, and a failure of imagination
  • The ticket: a file descriptor
  • The rack: each process has a descriptor table
  • Changing what is behind a number: dup2
  • One ticket handed down: the pipe
  • The rack has a size: the descriptor limit

Terms it explains: file descriptor, descriptor table, dup2, pipe, descriptor limit, blocking I/O, bootloader (GRUB), bus, device driver, DMA, event loop, firmware (BIOS/UEFI), I/O-bound vs CPU-bound, init / systemd, interrupt, ISR / interrupt handler, memory-mapped I/O, non-blocking / async I/O, polling, timer interrupt.

Lab

The device taps the CPU on every event. What happens when it taps a million times a second?

Open Let the device tap you every time, push Events a second arriving to the top, and watch the share of arrivals handled.

Open The interrupt storm

Your write returned and the power cut a moment later. Is the record on the disk?

Click After every record, then Every 1,000 records, drag Where the power cuts, and watch Lost on the crash.

Open The fsync interval

Review How Computers Work