Saturday 21 October 2017

Hardware interrupt vs Software Interrupt

The only difference is how they are triggered. A hardware interrupt is triggered by hardware (typically some peripheral external to the CPU such as a network adapter, sound chip, etc.) whereas a software interrupt is caused by software itself, much like a function call.

In both cases of HW and SW interrupts, control is redirected to an interrupt service routine whose job is to take any necessary action, and then return control back to the point where the interrupt took place. 

Often the goal in the interrupt routine is to do the minimum work necessary to return control to the previous program.
==================

Edge triggering  happens when some stimulus changes; level-triggered  things happen when some stimulus crosses a threshold. In the case of  digital circuits, the stimulus is voltage on a wire -- edge-triggered  things happen when the voltage changes, level-triggered things happen  when the voltage is above or below some pre-set amount.  

===========

Signals and interrupts are asynchronous --- meaning, they can arrive at any point in your program.

Exceptions are synchronous --- they happen when and because your program made them happen.   e.g. memory-reference errors --- can get turned into exceptions by the low-level signal handler in the runtime). 


=========================== 

Exceptions are mostly errors generated by different modules in programs that cause immediate termination if not ‘caught’.
Interrupts are a totally different thing. They are used to control how stuff happen in a computer.
Interrupts can be generated by both hardware and software. Every time an interrupt is generated the processor stops whatever it is doing and the interrupt handler is called to take appropiate action.
For example when you press a key, an interrupt with a specific code is generated, and the processor jumps to the first address in memory(this is the place where the interrupt handler is located). Now the interrupt handler sees what happened by reading the code and noticed it was a key press, then it tells the kernel about this key press to do whatever with it.
 ===========================

 

No comments:

Post a Comment