Operating system/Traps and Interrupts

From Wikiversity
Jump to navigation Jump to search

This is a lesson in in the course, Operating system, which is a part of The School of Computer Science

Objective[edit | edit source]

Interrupts[edit | edit source]

Overview[edit | edit source]

In OS development, interrupts are signals that suspends operation the computer is executing and jumps to an interrupt handler, or also known as an Interrupt Service Routine. The interrupt handler executes some code and finally does an interrupt return, which gives back control to whatever code was executing before the interrupt was triggered the interrupt.

Interrupt Vector Table[edit | edit source]

The interrupt vector table, or IVT for short, contains 256 possible interrupts in real mode. The position of the IVT is located at position 0000h:0000h. Each interrupt entry is the size of a dword (four bytes). The first word (two bytes) in the entry contains the address of the interrupt handler. The second word (two bytes) contains the segment of the interrupt handler. Since you can only have a maximum of a 20-bit address in real mode, interrupt handlers must remain within conventional memory (the first 640 kibibytes).

An easy way to setup up your own IVT is to:

  1. Boot into real mode. This is the default boot mode on all x86 computers.
  2. Null out a segment register.
  3. Set the index register (BX) to the value of the interrupt multiplied by four. (For example, lets create a MS-DOS interrupt handler. We would set our register with 21h * 4 = 84h).
  4. Now your segment register and index register points to your interrupt's entry, in this case int 21h. You can put your interrupt handler's address here.
  5. Next, simply increase the index register by 2.
  6. Now you can put the interrupt handler's segment of the into the interrupt's entry.
  7. congratulations, you now have a working int 21h.

Interrupt Descriptor Table[edit | edit source]

Assignments[edit | edit source]

Completion status: this resource is just getting off the ground. Please feel welcome to help!