Wednesday, February 19, 2014

What is the difference between interrupt/software interrupt and exception context?

What is the difference between interrupt/software interrupt and exception context?

Interrupt is an as asynchronous event that is typically generated by hardware(Ex, I/O) not in sync with processor instruction execution. While exceptions are synchronous events generated when processor detect any predefined condition while executing instruction.

Interrupt handler may be interrupted by another interrupt handler and so on. An interrupt handler may defer an exception handler, but an exception handler never defers an interrupt handler.The only exception possible in kernel mode is the page fault.

A software interrupt (OR Programmed Exceptions) occur at the request of the programmer. For example, A timer interrupt, system calls in Linux. Software interrupt is a considered to be an exception because they are synchronous.


Hardware Interrupt: This interrupt is caused by some external device such as request to start an I/O or occurrence of a hardware failure.
Software Interrupt: This interrupt can be invoked with the help of INT instruction. A programmer triggered this event that immediately stops execution of the program and passes execution over to the INT handler. The INT handler is usually a part of the operating system and determines the action to be taken e.g. output to the screen, execute file etc.
Thus a software interrupt as it’s name suggests is driven by a software instruction and a hardware interrupt is the result of external causes.
What Robert Love says about Exceptions...
In OS texts, exceptions are often discussed at the same time as interrupts. Unlike interrupts,exceptions occur synchronously with respect to the processor clock. Indeed, they are often called synchronous interrupts. Exceptions are produced by the processor while executing instructions either in response to a programming error (for example, divide by zero) or abnormal conditions that must be handled by the kernel (for example, a page fault). Because many processor architectures handle exceptions in a similar manner to interrupts, the linux kernel infrastructure for handling the two is similar.

No comments:

Post a Comment