Day 69 - Operating System Interrupts

So far I have wrote about what Operating Systems are but now I will start writing about how it works and what makes it work but before going into details I will write about Interrurpts. So what are interrupts?

What Are Interrupts?

An interrupt is a hardware-generated change-of-flow within the system. Interrupt is way for electronic devices to tell the CPU that they need attention because their state just changed. When an interrupt happens the processor will call the function to interrupt handler and stops the current running process, saves it state and executes the interrupt function and after handeling the interrupt it will get back to the process that it stopped before the interrupt.

Common functions of Interrupt are following.

  • When an interrupt occurs, the interrupt handler which will look for the appropriate services to handle the interrupt.
  • Incoming interrupts must be put on hold until the current interrupt is not handled. This is to prevent the interrupts for being lost or overwritten.
  • An interrupt is generally caused by the hardware device to let CPU know that some data has been read from the device and is waiting for it to be processed.
  • An OS is interrupt driven which means that the OS will be idle if there is not interrupt.
  • The OS must save the state and addresses of the current running process before handeling the interrupt.
  • The OS must know which device generated the interrupt. This is done either by checking every device for state change or checking the identity of the interrupt generating device by vectored interrupt system.
  • The OS must provide the segment code for all kind of interrupts that it can encounter.

Types Of Interrupts

Following are the types of interrutps that are mostly encountred by the system.

Supervisor Call Interrupts

The type of interrupts that are initiated by the running process that executes the Supervisor Call instruction are called Supervisor Call Interrupts. For example this could be in form of a user request asking for performing I/O functions to obtains input for the input device.

I/O Interrupts

I/O interrupts occur when the state of the I/O devices changes. For example when the I/O device is ready or get an error.

External Interrupts

External Interrupts are caused by many events. It can be caused by the the clock or by pressing the interrupting key or by an other processor in a multiprocessor unit.

Restart Interrupts

These interrupts occur when restart button is pressed or restart signal is received from the processor.

Program Check Interrupts

These kind of interrupts are caused by the programs executing the machine language instructions. For example an interrupt will occur when you try to divide by zero or when the provided data is in wrong format.

Machine Check Interrupts

The interrupts that occur when some hardware does not functions properly.


zainscizainsci