Bird
0
0

In a system using xTaskNotifyGive() as a lightweight semaphore, what happens if Task2 calls xTaskNotifyGive() twice before Task1 calls ulTaskNotifyTake() once?

hard📝 Application Q9 of 15
FreeRTOS - Task Notifications
In a system using xTaskNotifyGive() as a lightweight semaphore, what happens if Task2 calls xTaskNotifyGive() twice before Task1 calls ulTaskNotifyTake() once?
ATask1 blocks indefinitely waiting for two notifications.
BTask1's ulTaskNotifyTake() returns 2, counting both notifications.
CTask1 only receives one notification; the second is lost.
DSystem crashes due to notification overflow.
Step-by-Step Solution
Solution:
  1. Step 1: Understand notification counting

    xTaskNotifyGive() increments the notification count each time it is called.
  2. Step 2: Effect on ulTaskNotifyTake()

    ulTaskNotifyTake() returns the count of notifications received, so two calls result in a count of 2.
  3. Final Answer:

    Task1's ulTaskNotifyTake() returns 2, counting both notifications. -> Option B
  4. Quick Check:

    Notification count accumulates = C [OK]
Quick Trick: Multiple notifyGive calls accumulate count [OK]
Common Mistakes:
  • Assuming notifications overwrite each other
  • Expecting blocking for multiple notifications
  • Thinking system crashes on multiple notifications

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes