Skip to content

Manage interrupts carefully

philippemilletresearch edited this page Jan 30, 2019 · 4 revisions

Guideline Information

Item Value
Guideline Number 41
Guideline Responsible (Name, Affiliation) Philippe Millet, Thales
Guideline Reviewer (Name, Affiliation) Magnus Peterson, Synective
Guideline Audience (Category) Application developers
Guideline Expertise (Category) OS designers, Application developers
Guideline Keywords (Category) optimisation

Guideline advice

Interrupts must be managed with great care not to impact the performance of the system. The processor must not spend too much time in interrupts.

Insights that led to the guideline

Real-time applications typically receive data and process it at the same pace. Generally the sensor delivers an interrupt when data is available. While the interrupt allows the processing system real-time reaction to the incoming data, the management of this interrupt can lead to very poor performance if done with no care.

Recommended implementation method of the guideline along with a solid motivation for the recommendation

A very poor way to manage interrupts would be to call the processing function from the interrupt itself, because it then prevents the system from being able to manage any new interrupts. The full processing must be done outside of the interrupt routine. The handling of the interrupt must be as short as possible, taking care of for example buffer management by updating its status.

If the system spends too much time inside an interrupt and cannot serve all the pending interrupts that occurs while already serving a previous interrupt, then the system might lose interrupts and data can also be lost. Thus the system will not be able to keep processing data at real-time. The system will also not be able to answer other requests which might lead the other components on the system to wait for a response and slow down the whole processing chain.

Do not forget that the processor will need to save registers or swap context while entering an interrupt. So, another impact of having too much code in the interrupt is the necessity to save a lot of registers, which takes a long time, each time the processor enters anew the interrupt management code.

The programmers generally allocate a circular buffer in the global memory to receive the sensor data. The depth of this circular buffers must be computed according to the data flow to overcome potential concertina effect and keep the ability of the system to receive the sensor data.

Accelerators often use long processing pipeline. This is very efficient to process big bursts of data. Since interrupts will break the instruction pipeline, interrupts must be avoided or reduced in these computation phases. A good way to manage this is to prevent the system from entering into interrupts by masking the interrupts and then unmasking them periodically after each burst of data is computed. The size of the burst is to be defined by the application developer and the system architect.

Instantiation of the recommended implementation method in the reference platform

The management of interrupts is done through the operating system.

Evaluation of the guideline in reference applications

In the reference application, we use interrupts to manage the incoming data from the camera. The data is received in a buffer in DDR. The camera sends an interrupt which is received by the operating system. The operating system manages the buffers and sends a signal to the application. The application is informed that data is available and starts to process it asynchronously.

References

Review

Related guidelines

none

Clone this wiki locally