Standard ISR processing will typically involve recording the reason for the interrupt, clearing the interrupt, then performing any processing necessitated by the interrupt, all within the ISR itself.
Deferred interrupt processing will typically involve recording the reason for the interrupt and clearing the interrupt within the ISR, but then unblocking an RTOS task so the processing necessitated by the interrupt can be performed by the unblocked task, rather than within the ISR.
If the task to which interrupt processing is deferred is assigned a high enough priority then the ISR will return directly to the unblocked task (the interrupt will interrupt one task, but then return to a different task), resulting in all the processing necessitated by the interrupt being performed contiguously in time (without a gap), just as if all the processing had been performed in the ISR itself. This can be see in the image below, where all the interrupt processing occurs between times t2 and t4, even though part of the processing is performed by a task.
With reference to the image above:
Most embedded engineers will strive to minimise the amount of time spent inside an ISR (to minimise jitter in the system, enable other interrupts of the same or lower priority to execute, maximise interrupt responsiveness, etc.), and the technique of deferring interrupt processing to a task provides a convenient method of achieving this. However, the mechanics of first unblocking, and then switching to, an RTOS task itself takes a finite amount of time, so typically an application will only benefit from deferring interrupt processing if the processing:
Centralised deferred interrupt handling is so called because each interrupt that uses this method executes in the context of the same RTOS daemon task. The RTOS daemon task is created by FreeRTOS, and is also known as the timer service task.
To defer interrupt processing to the RTOS daemon task pass a pointer to the interrupt processing function as the xFunctionToPend parameter in a call to xTimerPendFunctionCallFromISR() API function. See the xTimerPendFunctionCallFromISR() documentation page for a worked example.
Advantages of centralised deferred interrupt handling include minimal resource usage, as each deferred interrupt handler uses the same task.
Disadvantages of centralised deferred interrupt handling include:
Application controlled deferred interrupt handling is so called because each interrupt that uses this method executes in the context of a task created by the application writer. See the Using an RTOS Task Notification as a Light Weight Counting Semaphore documentation page for a worked example.
Advantages of application controlled deferred interrupt handling include:
Disadvantages of application controlled deferred interrupt handling includes the greater consumption of resources as typically more tasks are required.