CSE Roadmap

Core tier · about 3 hours · 7 parts

Part 1 of 7 · 1 min read

Why this page comes fifth

In this module you will

  • Name the layers between a read call and the device, and say what each layer does.
  • Tell a block device from a character device, and read a major and minor number.
  • Explain what a device driver is and why the kernel gives all devices a uniform interface.
  • Explain buffering, caching and the page cache, and measure their effect.
  • Tell blocking, non-blocking and asynchronous I/O apart, and show a non-blocking read in C.

Page 4 showed how one driver talks to one controller with registers, interrupts and DMA. A real kernel must serve hundreds of different devices with the same system calls. This page shows the layers that make that possible. It connects the system calls of Level 0 with the hardware of the earlier pages, and prepares for the file systems of Level 9.

About this example About this example

Real: The two C programs of sections 4 and 5 were compiled with gcc -Wall -Wextra and run on a Linux test machine (2 processors, 8 GiB of memory, kernel 6.18, glibc 2.39). The device listing in section 2 comes from ls -l /dev and /proc/devices on that machine.

Scripted: The layer diagram in section 1 is a simplified drawing. The 1 GiB test file holds random bytes created for the test.

Not real: The test machine has a virtual disk that is backed by the host's own cache. The first read of a fresh file once took 43 seconds, much longer than any later run, because the host had to fetch it. The timings of section 4 are from later runs and do not describe a spinning disk.