Bird
0
0

What is wrong with this usage of xTaskNotifyGive() and ulTaskNotifyTake()?

medium📝 Debug Q7 of 15
FreeRTOS - Task Notifications
What is wrong with this usage of xTaskNotifyGive() and ulTaskNotifyTake()?
void Task1(void *pvParameters) {
    ulTaskNotifyTake(pdFALSE, portMAX_DELAY);
}

void Task2(void *pvParameters) {
    xTaskNotifyGive(Task1Handle);
}
AulTaskNotifyTake() cannot block indefinitely.
BxTaskNotifyGive() requires a second parameter.
CulTaskNotifyTake() should use pdTRUE to clear notification count.
DTask2 should not notify Task1 directly.
Step-by-Step Solution
Solution:
  1. Step 1: Understand ulTaskNotifyTake() clear parameter

    pdTRUE clears the notification count on exit; pdFALSE does not, which can cause unexpected behavior.
  2. Step 2: Identify correct usage

    Using pdFALSE means notifications accumulate, which is usually not desired for semaphore behavior.
  3. Final Answer:

    ulTaskNotifyTake() should use pdTRUE to clear notification count. -> Option C
  4. Quick Check:

    Clear notification with pdTRUE = D [OK]
Quick Trick: Use pdTRUE in ulTaskNotifyTake() to clear notifications [OK]
Common Mistakes:
  • Using pdFALSE causing notification count issues
  • Adding extra parameters to xTaskNotifyGive()
  • Misunderstanding notification clearing

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes