Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens in the x86 architecture when an interrupt occurs?

I'm studying x86 and Real Time Systems, and I have a question, that is:

Which steps x86 follows to handle any interrupt ?

like image 825
Mehmet Ali Avatar asked May 24 '10 14:05

Mehmet Ali


2 Answers

When an interrupt occurs, the CPU does the following:

  • Push the current address (contents of the Instruction Pointer) onto the stack; also, push the processor flags (but not all the other processor registers)
  • Jump to the address of the ISR (Interrupt Service Routine), which is specified in the Interrupt Descriptor Table.

The ISR should do the following:

  • Push any registers which it intends to alter (or, push all registers)
  • Handle the interrupt
  • Reenable interrupts
  • Pop any registers which it pushed
  • Use the IRET instructions, which pops the CPU flags and Instruction Pointer value from the stack (and thus returns to whatever was executing when the interrupt occured).
like image 74
ChrisW Avatar answered Sep 25 '22 08:09

ChrisW


Start here with the Interrupt Descriptor Table. Basically, when an interrupt occurs, flow control jumps to this table and then on to whatever is in this table. Also, I believe all registers are pushed as soon as the interrupt occurs, but I'm not 100% certain of this as it's been a long, long time since I've dealt with this.

like image 25
Michael Dorgan Avatar answered Sep 22 '22 08:09

Michael Dorgan