Device driver and interrupt concepts
Quick answer
A driver connects a device to the kernel interfaces that use it. Binding associates a matching driver with a device; an interrupt reports an event that may require attention. A driver must coordinate initialization, concurrency and cleanup, not just recognize hardware.
Separate device discovery, driver binding and successful I/O. Seeing a device in an inventory does not establish that its driver initialized correctly. During removal, pending work must be stopped before resources are released.
Prepare the practice environment
Run python3 lab-fixtures/advanced-kernel/setup.py from the extracted root as an ordinary user. Enter the printed private path and check pwd. Use fresh fixtures, Bash with set -e -o pipefail, LC_ALL=C and umask 077. The helper reads fictional records. No root, external network, module load or BPF attachment is required. Optional hardware inspection requires an authorized VM.
Prerequisites
Review: Kernel build and module lab planning.
How it works
The bus discovers or describes devices. Matching rules differ across PCI, USB and platform devices; a match may lead to a driver's probe() callback. Probe can fail or defer, so identification is not proof of binding. Initialization typically acquires resources, sets up state and registers relevant interfaces; removal releases resources and stops asynchronous work in a safe order. Interrupt handling depends on device and architecture. A hard interrupt handler must not sleep; where appropriate a threaded handler or deferred work performs longer processing. Shared interrupts may require checking whether the device generated the event. DMA lets a device transfer data through mappings managed by the driver and kernel; correct synchronization and lifetime matter. lspci -nnk reports PCI identifiers and available driver information; lsusb lists USB devices. Do not confuse device IDs, driver names and device nodes. Use read-only inspection on an authorized VM; never unbind real hardware or write sysfs attributes for this exercise. Our fictional lifecycle assumes one device, one driver and a single pending event.
Try the examples
The helper checks the ordering of fictional events, including draining pending work before removal. It is not a driver.
Expected stdout:
matched -> probed -> IRQ queued -> work complete -> removedDifferences over the same interval show distribution, not handler time or CPU saturation.
Expected stdout:
CPU0 +12; CPU1 +3; total +15Optional read-only command for an authorized VM with pciutils. Output is hardware-dependent. Do not share raw inventory publicly.
Manual example; not executed locally. Follow its stated environment restrictions.
Common mistakes
Do not assume a driver match means probe succeeded, that every interrupt requires a thread switch, or that a high interrupt count proves a performance problem. Never unbind production devices to test a theory.
Practice
Reorder the fictional events in driver.json so removal occurs before pending work completes. Predict why that is invalid; run the original model and explain the expected cleanup order. Use only offline fixture copies.
Related references
Study: lspci, lsusb. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Device driver and interrupt concepts — Knowledge Check
Apply kernel engineering concepts to concrete local examples.
What can happen after matching a driver?
Can a hard interrupt handler sleep?
What does an interrupt counter delta show?
What must removal consider?