Bird
0
0

Consider this FreeRTOS ISR snippet:

medium📝 Predict Output Q13 of 15
FreeRTOS - Interrupt Management
Consider this FreeRTOS ISR snippet:
void ISR_Handler() {
  BaseType_t xHigherPriorityTaskWoken = pdFALSE;
  xSemaphoreGiveFromISR(&xSemaphore, &xHigherPriorityTaskWoken);
  portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
What is the main effect of calling portYIELD_FROM_ISR(xHigherPriorityTaskWoken);?
AIt disables all interrupts until the next tick.
BIt forces a context switch if a higher priority task was woken.
CIt delays the ISR execution by one tick.
DIt resets the semaphore to zero.
Step-by-Step Solution
Solution:
  1. Step 1: Understand portYIELD_FROM_ISR usage

    This macro requests a context switch if a higher priority task was woken by the ISR.
  2. Step 2: Analyze the effect on task scheduling

    If xHigherPriorityTaskWoken is true, the scheduler switches to that task immediately after ISR.
  3. Final Answer:

    It forces a context switch if a higher priority task was woken. -> Option B
  4. Quick Check:

    portYIELD_FROM_ISR triggers context switch [OK]
Quick Trick: portYIELD_FROM_ISR triggers immediate switch if needed [OK]
Common Mistakes:
  • Thinking it disables interrupts
  • Assuming it delays ISR
  • Believing it resets semaphores

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes