Bird
0
0

Given the following FreeRTOS ISR code snippet, what will be the value of xHigherPriorityTaskWoken after execution?

medium📝 Predict Output Q13 of 15
FreeRTOS - Interrupt Management

Given the following FreeRTOS ISR code snippet, what will be the value of xHigherPriorityTaskWoken after execution?

void ISR_Timer(void) {
    BaseType_t xHigherPriorityTaskWoken = pdFALSE;
    xSemaphoreGiveFromISR(xSemaphore, &xHigherPriorityTaskWoken);
    portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}

Assume the semaphore unblocks a higher priority task waiting.

AUndefined behavior
BpdFALSE
CpdTRUE
DSemaphore handle value
Step-by-Step Solution
Solution:
  1. Step 1: Understand xSemaphoreGiveFromISR behavior

    This function sets xHigherPriorityTaskWoken to pdTRUE if a higher priority task is unblocked.
  2. Step 2: Given higher priority task is unblocked

    Since the semaphore unblocks a higher priority task, xHigherPriorityTaskWoken becomes pdTRUE.
  3. Final Answer:

    pdTRUE -> Option C
  4. Quick Check:

    Higher priority task unblocked = xHigherPriorityTaskWoken pdTRUE [OK]
Quick Trick: xHigherPriorityTaskWoken is pdTRUE if higher priority task unblocked [OK]
Common Mistakes:
  • Assuming xHigherPriorityTaskWoken stays pdFALSE always
  • Confusing semaphore handle with boolean flag
  • Ignoring the effect of unblocking higher priority tasks

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes