Starfield Almanac

Ivthandleinterrupt

ivthandleinterrupt(vector, stacked_frame):
    save_cpu_state()
    if vector invalid: goto end
    irq_info = lookup(vector)
    source = detect_source(irq_info)
    handler = irq_info.handler
    if handler:
        handled = handler(stacked_frame, irq_info.dev)
        if not handled and irq_info.chained_handlers:
            try chained handlers
    if handler requested deferred_work:
        schedule_deferred_work(irq_info.work)
    send_eoi_to_controller(irq_info.controller)
end:
    restore_cpu_state()
    return_from_interrupt()

If you want platform-specific code (x86_64 assembly + C wrapper, or ARM Cortex-M C example), specify target architecture and calling convention and I will provide a compact sample.

  • Per-CPU handling: route interrupts and maintain counters per CPU for performance and locality.
  • Vector chaining: allow multiple handlers to register for a vector (common in legacy systems); the ivthandleinterrupt iterates chain until handled.
  • Interrupt affinity and load balancing: assign device interrupts to CPUs to optimize cache locality and throughput.
  • Locking and synchronization: use appropriate spinlocks / lock-free structures given you're in interrupt context.
  • You’ll most likely encounter ivthandleinterrupt in: ivthandleinterrupt

    Example panic log snippet:

    Panic(CPU 2): Unhandled interrupt (IRQ 42)
    Backtrace: ivthandleinterrupt -> interrupt_processor_dispatch -> kernel_trap