Specifications
Use Nested Hardware Interrupts
By default, the HAL disables interrupts when it dispatches an ISR. This means that only one ISR can
execute at any time, and ISRs are executed on a first-come first-served basis. This reduces the system
overhead associated with interrupt processing, and simplifies ISR development. The ISR does not need to
be reentrant. ISRs can use and modify any global or static data structures or hardware registers that are
not shared with application code.
However, first-come first-served execution means that the HAL hardware interrupt priorities only have
an effect if two IRQs are active at the same time. A low-priority interrupt occurring before a higher-
priority interrupt can prevent the higher-priority ISR from executing. This is a form of priority inversion,
and it can have a significant impact on ISR performance in systems that generate frequent interrupts.
A software system can achieve full hardware interrupt prioritization by using nested ISRs. With nested
ISRs, higher-priority interrupts are allowed to interrupt lower-priority ISRs.
This technique can improve the response time for higher-priority interrupts.
Note:
Nested ISRs increase the processing time for lower-priority hardware interrupts.
If your ISR is very short, it might not be worth the overhead to enable nested hardware interrupts.
Enabling nested interrupts for a short ISR can actually increase the response time for higher-priority
interrupts.
Note:
If you use a separate exception stack with the IIC, you cannot nest hardware interrupts.
For more information about separate exception stacks, refer to Use a Separate Exception Stack.
Related Information
Use a Separate Exception Stack on page 8-19
Nested Hardware Interrupts with the Internal Interrupt Controller
To implement nested hardware interrupts with the IIC, use the alt_irq_interruptible() and
alt_irq_non_interruptible() functions to bracket code in a processor-intensive ISR. The call to
alt_irq_interruptible() adjusts the interrupt mask so that higher-priority interrupts can take control
from the running ISR. When your ISR calls alt_irq_non_interruptible(), the interrupt mask is
returned to its previous state.
Note:
If your ISR calls alt_irq_interruptible(), it must call alt_irq_non_interruptible() before
returning. Otherwise, the HAL exception handling system might lock up.
Nested Hardware Interrupts with an External Interrupt Controller
The HAL enhanced interrupt API supports nested hardware interrupts, also known as interrupt pre-
emption. A device driver must be specifically written to function correctly under pre-emption.
Legacy device drivers do not publish the isr_preemption_supported property. Therefore the SBT
assumes that they do not support pre-emption. If your legacy custom driver supports pre-emption, and
you want to allow pre-emption in the BSP, you must update the driver to use the enhanced HAL interrupt
API.
The HAL enhanced interrupt API also supports automatic pre-emption. Automatic pre-emption means
that maskable exceptions remain enabled when the processor accepts the hardware interrupt.
For more information about pre-emption with an EIC, refer to the “Managing Pre-Emption” chapter.
In the vector table, the HAL inserts a branch to the correct funnel for each hardware interrupt, depending
on the pre-emption settings.
NII5V2
2015.05.14
Use Nested Hardware Interrupts
8-21
Exception Handling
Altera Corporation
Send Feedback