Every running program is a process
When you open a program, Linux loads it into memory and runs it. That running copy is called a process. Run the same program twice and you get two processes.
Linux tells processes apart by giving each one a number, its PID (process ID). Lots of Linux tools work with PIDs. To stop a program, for example, you'd run kill 812.
ps lists processes, and the same row lights up in its output.The kernel runs everything, and keeps notes
Under every process sits the kernel, the core of Linux. A process isn't allowed to touch the disk, the screen or the network itself. It has to ask the kernel: "read this file for me", "send this to the screen". Each request like that is a system call.
Every request passes through the kernel, so the kernel knows everything about every process: its name, how much memory it uses, which files it has open, and how much it has read and written. It keeps a note for each process.
Those notes live inside the kernel's memory. A normal program can't look in there.
files open: 96
bytes read: 8,120,331
files open: 4
bytes read: 48,210
files open: 3
bytes read: 2,210
/proc lets you read the kernel's notes as files
So how do you see those notes? Linux shows them as folders and files under /proc. Each process gets a folder named after its PID, like /proc/4242. Inside are small text files, each holding one part of the note.
Any tool that can read a file can now read the notes: cat, Python, your own code. You don't need a special tool.
Nothing in /proc is stored on a disk. When you open one of these files, the kernel writes the text right then, from its notes, and hands it to you. That's why every file there says its size is 0.
/proc/self means "me"
A program often wants its own note. It could find out its PID first and then open /proc/4242/…, but there's a shortcut: /proc/self.
When a process opens /proc/self, the kernel points it at that process's own folder. The same path leads somewhere different depending on who opens it.
So /proc/self/io means "my own I/O note". That's the file this lab is about.
The io file counts reads and writes
Each time a process asks the kernel to read or write, the kernel adds to its counters. /proc/self/io prints those counters as seven lines, in two groups:
What the program asked for. Bytes read and written, and how many requests it made. That covers everything: files, the screen, the network.
What actually touched the disk. These can be much smaller, because the kernel keeps a copy of recently used files in RAM, called the page cache. A read served from RAM never touches the disk.
Why you'd ever read it
You now know the whole idea:
A process is a running program. The kernel does all its reading and writing and counts every byte. /proc lets you read the kernel's notes as files, and /proc/self/io is a process's own I/O counters.
Part 2 is a lab. You type commands into a process and watch every counter move, with a diagram showing where in the kernel each number gets counted.
Tools like iotop and htop read /proc/<pid>/io for every process and sort by write_bytes.
Read the file twice, ten seconds apart. The difference is its speed.
A huge number of requests (syscw) for very few bytes (wchar) means it writes in tiny pieces. That's a classic bug and easy to fix.