Embbyte : 12 Jul : Interrupts Detection : How processor detects that there is an interrupt pending on interrupt line

I was asked an interesting question by a fellow team member – ” how the processor comes to know that interrupt has been raised ( on the IRQ line )”- the answer to which was – Processor samples the IRQ (in ARM) / interrupt line at a fixed interval of time  which may be equal to a few bus cycles , or for eg after every instruction execution.If there is a change on the line in accordance with the interrupt configuration (Edge triggered or level triggered), the processor comes to know that interrupt has been raised.

The next question was “Isn’t it also a kind of  polling then?”.Yes.It is polling indeed but better in terms of performance than polling each device in turn for interrupt request.We “sample” just one line at a particular time interval.

This Q-A session motivated me to return to my favorite online resource on interrupt handling in ARM  by Andrew N. Sloss. This one is to be kept handy when you are implementing interrupts or handling interrupts in ARM.

Also , William Stallings is his book  ” Operating Systems : Internals and Design Principles ” has explained it in the following manner :

To accommodate interrupts , an “interrupt stage”  is added to the instruction cycle.In the interrupt stage , the processor checks to see if any interrupts have occurred ,indicated by the presence of an interrupt signal.If no interrupts are pending , the processor proceeds to the fetch stage and fetches the next instruction of the current program.If an interrupt is pending , the processor suspends execution of the current program and executes an interrupt-handler  routine.The interrupt-handler routine is generally part of OS.Typically , this routine determines the nature of the interrupt and whatever actions are needed.

Here is the diagram from the book which explains it all :

14July_2013 044-001

 

 

Contrast it with the basic  instruction  cycle which we study :

14July_2013 046-001

 

Images courtesy : Operating Systems, Internals and Design Principles,William Stallings

 

 

 

 

Embedded Linux training material

A great great link

 

http://free-electrons.com/docs/

 

I am gonna add this to my links section next.

 

I really liked the pdfs which I went through