-1

To handle an interrupt the processor jumps to an interrupt service routine (ISR). If this ISR generates the same interrupt then this can result in:

a) program error

b) hardware error

c) stack overflow

This is a question asked in a university entrance exam and I am a computer science student. Is it possible to have same interrupt whilst executing the ISR?

David
  • 4,560
  • 2
  • 26
  • 45
user1766481
  • 91
  • 1
  • 1
  • 9

2 Answers2

2

On most simple microcontrollers interrupts should be disabled during the interrupt service routine (ISR). For example on basic PICs the processor ensures this by clearing the GIE bit in INTCON to prevent additional interrupts from occurring.

On complex processors things get more complicated as there are interrupt priorities and often different types of interrupt, some which will need dealing with immediately.

If your question is multiple choice it is hard to answer as any of those three options are possible. It will depend on the processor.

You might like to read up about reentrancy, specifically the section about reentrant interrupt handlers. ARM have a good document about reentrant ISRs relevant to their processors and there is a question on the main StackOverflow about the same topic.

David
  • 4,560
  • 2
  • 26
  • 45
  • I have just seen the link that alexan_e posted which has an excellent answer from Olin, I thoroughly recommend you read that for an in-depth version of what I answered here. – David Jan 04 '14 at 09:27
2

Without further information this question is impossible to answer.

I teach various computer-related subjects, but I don't know for certain what a "program error" is supposed to mean. Is it something hardware-detected (like a page fault)? Or is it that the code does not do what the programmer intended it to do?

Whether a hardware error will occur depends on the hardware used! In general, this will not be the case.

The question might mean that the ISR always generates the same interrupt again. On a chip that disables interrupts up to the interrupt-return (PIC) this new interrupt could

  • simply be ignored (when the ISR clears the interrupt at the end), or
  • result in infinite re-activation of the interrupt (when the ISR clears the interrupt before it causes it again) - this could be intentional or not (= program error??)

On chips that allow an interrupt to interrupt itself (AFAIK this is rare) the infinite recursion would cause a stack overflow. (Which could manifest itself as a page fault. Is that a hardware error?)

If the question means that an interrupt occasionally causes same interrupt it is very likely that nothing special will happen, although the second interrupt might not be handled (But again, this depends on how the chip handles nested interrupts and how the ISR is coded.)

Wouter van Ooijen
  • 48,572
  • 1
  • 63
  • 136