CSE Roadmap

Core tier · about 3 hours · 6 parts

Part 1 of 6 · 1 min read

Why this page comes second

In this module you will

  • Explain what /proc and /sys are and why reading them costs no disk I/O.
  • Read the main per-process files: status, cmdline, cwd, exe, limits, fd, io and maps.
  • Read the main system files: meminfo, loadavg, stat, interrupts and mounts.
  • Compute the CPU shares from the first line of /proc/stat.
  • Write a short C program that lists processes by reading /proc, and see that tools like ps do the same.

Page 1 showed tools whose numbers came from somewhere. This page opens that source. It uses the special file systems of Level 9 (the VFS asked "what is a file?" and the answer included files that are not on a disk), the process fields of Level 1, the memory fields of Levels 6 and 7 and the disk settings of Level 8. Page 3 then traces what a program asks of the kernel, and page 4 uses /proc numbers to find performance problems.

About this example About this example

Real: Every file content and every output was read on a Linux test machine (kernel 6.18, 2 processors, 8 GiB). The C program was compiled with gcc -Wall -Wextra and run there.

Scripted: The comparison with ps -e (same count of 68 lines in both) is a check made on that machine at that moment, and the counts differ when processes start or end between the two runs.

Not real: The test machine is a virtual machine in a container layer, so some files, for example the interrupt list, show virtual devices (Level 11). The CPU-share example uses one reading of /proc/stat and is not an average over a working day.