Tasks
The same steps as the lab slide. Do them on a Linux PC with the files from the zip; the tools below help you check your thinking first.
Lab 13 · Interrupts and Exceptions
- TODO 1 in irqtop_starter.c: read the header line; count "CPU" with strstr → ncpu
- TODO 2: for each line: the id before ':', the sum of up to ncpu numbers (strtoull), the name
- TODO 3: match lines of the two snapshots by id (strcmp); count = after − before
- TODO 4: qsort by count, biggest first; print the top 10
- Run it idle; then type, copy a big file, run yes > /dev/null: which lines change?
reference, real
$ ./irqtop # test machine, idle
IRQ per second name
LOC 92 Local timer interrupts
CAL 25 Function call interrupts
49 3 … virtio7-input.0
$ ./irqtop 6 # while reading files
IRQ per second name
37 138 … virtio1-req.0
LOC 92 Local timer interrupts
CAL 26 Function call interrupts
$ ./irqtop # QEMU guest, dd
25 493 … virtio0-req.0
LOC 351 Local timer interrupts
Careful: the lines ERR and MIS have only ONE number, not one per CPU. strtoull tells you when it found no number: end == p.
Try it here
These run in your browser, with no server and no internet. They are built from the same reference programs as the lab, so their output matches what your finished C program should print. They do not replace the real lab: the kernel, gcc and your own code are the point.
Read the files
Every text file from lab13_files.zip. Read here, then download the zip to work on them.