Bird
0
0

Identify the error in this nested interrupt handling code snippet:

medium📝 Debug Q14 of 15
FreeRTOS - Interrupt Management

Identify the error in this nested interrupt handling code snippet:

void ISR_UART(void) {
    BaseType_t xHigherPriorityTaskWoken = pdFALSE;
    xQueueSendFromISR(xQueue, &data, NULL);
    portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
ABaseType_t should be int instead
BportYIELD_FROM_ISR should not be called inside ISR
CxQueueSendFromISR cannot be used in ISRs
DxHigherPriorityTaskWoken should be passed to xQueueSendFromISR
Step-by-Step Solution
Solution:
  1. Step 1: Check xQueueSendFromISR parameters

    The function requires a pointer to xHigherPriorityTaskWoken to update it if a higher priority task is woken.
  2. Step 2: Identify missing argument

    Passing NULL means xHigherPriorityTaskWoken is never updated, so portYIELD_FROM_ISR may not yield correctly.
  3. Final Answer:

    xHigherPriorityTaskWoken should be passed to xQueueSendFromISR -> Option D
  4. Quick Check:

    Pass xHigherPriorityTaskWoken pointer to FromISR APIs [OK]
Quick Trick: Always pass xHigherPriorityTaskWoken pointer to FromISR APIs [OK]
Common Mistakes:
  • Passing NULL instead of &xHigherPriorityTaskWoken
  • Calling portYIELD_FROM_ISR without updating flag
  • Using wrong variable types for task woken flag

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes