THINK FIRST·CODE LATER

← All labs

Linux in practice: watch system calls and interrupts

Problem

On a Linux machine (VM, WSL 2 or lab PC):

  1. strace -c ls / — which system calls does ls use most? How many in total?
  2. strace -e trace=openat,read,write,close cat /etc/hostname — follow the file: which call opens it, which reads it, which writes it to the screen? What file descriptor numbers do you see and why is output fd 1?
  3. Write a tiny Java (or C/Python) program that writes 100,000 characters one at a time with an unbuffered stream, and another with a buffered one. Run both under strace -c -f and compare the number of write calls and the time. (Java: FileOutputStream vs BufferedOutputStream.)
  4. cat /proc/interrupts — which devices have produced the most interrupts on each CPU? Run it twice 10 seconds apart and compute the rate for the timer and the network card.
  5. dmesg | head -30 (may need sudo) or journalctl -k -b | head -30 — find evidence of the boot sequence: kernel version, memory detected, first drivers.

Report your key output lines and explain each in 1–2 sentences using this chapter's vocabulary (trap, system-call table, file descriptor, interrupt, driver, buffering).

Work it out on paper, in a document or here, then compare with the model answer. Your answer stays in your browser — it is never sent to or stored on the server.