Skip to main content

Interrupt Handlers

Interrupt Vector Table

This table maps each interrupt id to the address of its handler.

why is it called vector

It's called a vector table because this table shows the direction where to go.

Hardware Interrupts

For hardware interrupts, the table holds the list of device drivers.

  1. During boot, the BIOS reads each device's config needs. It assigns an IRQ ID to each device and stores it in the config space.
  2. During kernel init, each device driver reads the IRQ ID from its device's config space. It then updates the IVT with its handler address for that IRQ ID.
Polling Interrupts

For hardware interrupts, the CPU polls the interrupt flag at set intervals.

This is why interrupts are always asynchronous.

Software Interrupts

This interrupt comes from userspace apps to the kernel. It asks for a service from the operating system.

During boot, the kernel registers itself as one of the handlers in the IVT table.

These software interrupts are called system calls.

ID of the software interrupt handler

In case of Linux, the ID of the software interrupt handler in the IVT is always 128 (0x80)

IRET is the instruction that switches the CPU mode back to user mode.

system call