ISR

What is Interrupt nesting?

Q: What is interrupt nesting?

Pre-Emption of low priority Interrupt by another high priority interrupt is known as Interrupt nesting.
If a high priority interrupt pre-empts the lower priority interrupt, then the higher priority Interrupt context would be saved on the previous lower priority one. We now say the depth is two and nesting is two.

Q: How is nesting of interrupt handled ?

Most architectures have two stacks. Task and Interrupt stack. The size of interrupt stack is decided by the maximum depth of nesting. If an ISR gets interrupted, the interrupt stack saves the context of the first interrupt service routine. The context here is generally all the registers, PC and local variables. When the second ISR executes its return from interrupt instruction, it pops back to the first ISR, stack,registers and interrupt level. Now when this first ISR routine executes return from interrupt, then it may back to the task level, the stack is restored to the task stack and the registers and processor level go back to the normal task level.

Q: How to avoid nesting of interrupts?

Nesting of interrupts can be avoided by disabling the interrupt as soon as interrupt service routine is invoked.
In most architecture, interrupts are automatically disabled on invoking ISR.

Q:For a level triggered interrupt, if the interrupts are not disabled, will it result in repeated invoking of ISR?

Yes. If an interrupt is level triggered, then you need to reset the level
when the interrupt is serviced. IF you fail to reset the interrupt
request, the interrupt will recur when interrupts (at that level) are
re-enabled. Usually that would be when the ISR returns.

Interrupt Handling, Interview Question for Embedded Systems Engineers

Q: How is ISR handled in vxworks ?
A: VxWorks supplies interrupt routines which connect to C functions and pass arguments to the functions to be executed at interrupt level.  To return from an interrupt, the connected function simply returns.  A routine connected to an interrupt in this way is referred to as an interrupt service routine (ISR) or interrupt handler.  When an interrupt occurs, the registers are saved, a stack for the arguments to be passed is set up, then the C function is called. On return from the ISR, stack and registers are restored.

Q: How do you connect the C Function to any interrupt?
A: Using intConnect(INUM_TO_IVEC(intNum), intHandler, argToHandler).
The first argument to this routine is the byte offset of the interrupt vector to connect to. The second argument is the interrupt handler and the last is any argument to this handler.

Q: Is the C Code directly vectored to Hardware interrupts using IntConnect? Explain?
A:No. Interrupts cannot actually vector directly to C functions. Instead, intConnect( ) builds a wrappper,a small amount of code, that saves the necessary registers, sets up a stack entry (either on a special interrupt stack, or on the current task's stack) with the argument to be passed, and calls the connected function. On return from the function it restores the registers and stack, and exits the interrupt;

Q: Does the ISR use the stack of interrupted Task? Explain?
A: It depends on system architecture.