concepts

Interrupts — Event Handling and Counters

Hardware interrupts notify CPUs of events; kernel interrupt handlers service them according to the interrupt controller and driver design. Some work runs in hard interrupt context and must respect non-sleeping constraints; threaded handlers and deferred mechanisms handle other work. Softirqs are a distinct kernel mechanism, and synchronous exceptions such as page faults are not ordinary device IRQs. /proc/interrupts may expose interrupt counts per CPU; these counters are not handler duration or CPU utilization. Compare the same interrupt and CPU columns across samples, accounting for reset, wrap, CPU hotplug and device changes. The example uses two fictional snapshots with matching labels and validates deltas, rejecting a decreasing counter rather than silently claiming a negative interrupt rate. No device is accessed and no interrupts are generated by the model. Example prerequisites: Linux, Bash and Python 3 standard library; run as a non-root user in a private temporary working directory. Example scope: synthetic model. Expected output: modeled IRQ delta: CPU0=12 CPU1=3; reset rejected. No system configuration changes.

Formal Syntax & Structure

linux syntaxlinux
/proc/interrupts (when exposed); per-CPU counter deltas

Parameters & Attributes

NameTypeDescription
IRQidentifierInterrupt line or kernel-reported interrupt label.
CPU columnscumulative countsCounts per reported CPU.
deltacountLater minus earlier for a comparable interval.

Return Value

Concept / observation

Synthetic example returns per-CPU count changes, not timing or live IRQ measurements.

Working Example

Example Snippetlinux
python3 - <<'PY'before={'CPU0':100,'CPU1':200}after={'CPU0':112,'CPU1':203}def delta(a,b):    if a.keys()!=b.keys() or any(b[k]<a[k] for k in a):        raise ValueError('incomparable snapshots')    return {k:b[k]-a[k] for k in a}result=delta(before,after)assert result=={'CPU0':12,'CPU1':3}try:    delta(before,{'CPU0':99,'CPU1':203})except ValueError:    passelse:    raise AssertionError('reset must be rejected')print('modeled IRQ delta: CPU0=12 CPU1=3; reset rejected')PY
Linux Reference