Bird
0
0

Which of the following sequences correctly implements this synchronization?

hard📝 Application Q8 of 15
FreeRTOS - Task Notifications
You want to synchronize two tasks using xTaskNotifyGive() as a lightweight semaphore. TaskA waits for a notification, and TaskB signals it. Which of the following sequences correctly implements this synchronization?
ABoth TaskA and TaskB call <code>xTaskNotifyGive()</code> simultaneously.
BTaskA calls <code>xTaskNotifyGive(TaskBHandle);</code> and TaskB calls <code>ulTaskNotifyTake(pdTRUE, portMAX_DELAY);</code>
CTaskA calls <code>ulTaskNotifyTake(pdTRUE, portMAX_DELAY);</code> and TaskB calls <code>xTaskNotifyGive(TaskAHandle);</code>
DTaskA and TaskB both call <code>ulTaskNotifyTake(pdTRUE, 0);</code> without notifications.
Step-by-Step Solution
Solution:
  1. Step 1: Identify waiting task

    TaskA should wait for the notification using ulTaskNotifyTake().
  2. Step 2: Identify signaling task

    TaskB signals TaskA by calling xTaskNotifyGive() with TaskA's handle.
  3. Step 3: Verify options

    TaskA calls ulTaskNotifyTake(pdTRUE, portMAX_DELAY); and TaskB calls xTaskNotifyGive(TaskAHandle); correctly matches this sequence. Others either reverse roles or misuse functions.
  4. Final Answer:

    TaskA calls ulTaskNotifyTake(pdTRUE, portMAX_DELAY); and TaskB calls xTaskNotifyGive(TaskAHandle); -> Option C
  5. Quick Check:

    Waiter uses ulTaskNotifyTake, Signaler uses xTaskNotifyGive [OK]
Quick Trick: Waiter uses ulTaskNotifyTake, Signaler uses xTaskNotifyGive [OK]
Common Mistakes:
  • Reversing roles of tasks
  • Both tasks calling notify or wait simultaneously
  • Using zero timeout without notifications

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes