Bird
0
0

Consider the following code snippet:

medium📝 Predict Output Q13 of 15
FreeRTOS - Task Notifications
Consider the following code snippet:
void Task1(void *pvParameters) {
    // Wait for notification
    ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
    // Continue after notification
    printf("Task1 resumed\n");
}

void Task2(void *pvParameters) {
    // Notify Task1
    xTaskNotifyGive(Task1Handle);
}
What will be printed when Task2 calls xTaskNotifyGive()?
ATask2 resumes instead of Task1
BTask1 resumed
CSyntax error at compile time
DNo output, Task1 blocks forever
Step-by-Step Solution
Solution:
  1. Step 1: Understand notification flow

    Task1 waits for a notification with ulTaskNotifyTake(). When Task2 calls xTaskNotifyGive(), it sends the notification.
  2. Step 2: Effect of notification

    The notification unblocks Task1, so it prints "Task1 resumed".
  3. Final Answer:

    Task1 resumed -> Option B
  4. Quick Check:

    Notification received = Task1 prints [OK]
Quick Trick: xTaskNotifyGive() wakes waiting task to continue [OK]
Common Mistakes:
  • Assuming Task1 never resumes
  • Confusing which task prints output
  • Thinking code causes compile error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes