Challenge - 5 Problems
Deferred Interrupt Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of deferred interrupt processing with task notification
Consider a FreeRTOS system where an ISR notifies a task to process data later. What will be the output when the task receives the notification?
FreeRTOS
#include "FreeRTOS.h" #include "task.h" #include <stdio.h> TaskHandle_t xTaskHandle = NULL; void vISR_Handler(void) { BaseType_t xHigherPriorityTaskWoken = pdFALSE; vTaskNotifyGiveFromISR(xTaskHandle, &xHigherPriorityTaskWoken); portYIELD_FROM_ISR(xHigherPriorityTaskWoken); } void vTaskFunction(void *pvParameters) { for (;;) { ulTaskNotifyTake(pdTRUE, portMAX_DELAY); printf("Task processed deferred interrupt\n"); } } int main() { xTaskCreate(vTaskFunction, "Task", 1000, NULL, 1, &xTaskHandle); // Simulate ISR call vISR_Handler(); // Normally scheduler would run, here we simulate one iteration vTaskFunction(NULL); return 0; }
Attempts:
2 left
💡 Hint
Think about how task notifications unblock the task exactly once per notification.
✗ Incorrect
The ISR sends a notification to the task, which unblocks the task once. The task then prints the message once. The simulated call to vTaskFunction after ISR processes the notification and prints the output once.
🧠 Conceptual
intermediateWhy use deferred interrupt processing in FreeRTOS?
Which of the following best explains the main reason to use deferred interrupt processing in FreeRTOS?
Attempts:
2 left
💡 Hint
Think about what is safe and recommended inside an ISR.
✗ Incorrect
Deferred interrupt processing moves heavy or blocking work out of the ISR into a task, keeping ISRs short and fast, which is critical for system responsiveness.
🔧 Debug
advancedIdentify the error in deferred interrupt processing code
What error will occur in this FreeRTOS ISR code snippet?
void vISR_Handler(void) {
vTaskNotifyGive(xTaskHandle);
}
Assume xTaskHandle is a valid task handle.
Attempts:
2 left
💡 Hint
Consider which FreeRTOS API functions are safe to call inside an ISR.
✗ Incorrect
Inside an ISR, the FromISR version of API functions must be used. Using vTaskNotifyGive inside ISR is unsafe and can cause runtime errors.
📝 Syntax
advancedCorrect syntax for deferred interrupt processing with queue
Which option shows the correct way to send data from an ISR to a task using a FreeRTOS queue?
Attempts:
2 left
💡 Hint
Inside ISR, use the FromISR version and handle the task wake flag.
✗ Incorrect
Inside an ISR, xQueueSendFromISR must be used with a pointer to a BaseType_t variable to indicate if a context switch is needed.
🚀 Application
expertDesign deferred interrupt processing for multiple interrupt sources
You have three different hardware interrupts that must notify a single task to process events. Which design pattern best ensures all events are processed without losing notifications?
Attempts:
2 left
💡 Hint
Consider how to count multiple events from different ISRs reliably.
✗ Incorrect
A counting semaphore allows multiple ISR events to be counted and ensures the task processes each event without missing any. Binary semaphores or single notifications can miss events if multiple occur before the task runs.
