0
0
FreeRTOSprogramming~20 mins

ulTaskNotifyTake() for binary/counting notification in FreeRTOS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
ulTaskNotifyTake Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of ulTaskNotifyTake() with clear count on binary notification?

Consider a FreeRTOS task that calls ulTaskNotifyTake(pdTRUE, 0) after receiving a single notification. What value does ulTaskNotifyTake() return?

FreeRTOS
/* Assume the task has received exactly one notification count before this call */
uint32_t count = ulTaskNotifyTake(pdTRUE, 0);
printf("%u", count);
A1
B2
C0
DError: function blocks and never returns
Attempts:
2 left
💡 Hint

Think about what pdTRUE does to the notification count.

Predict Output
intermediate
2:00remaining
What does ulTaskNotifyTake() return after multiple notifications with clear count?

A task receives 3 notifications before calling ulTaskNotifyTake(pdTRUE, 0). What is the return value?

FreeRTOS
/* Notifications sent 3 times before this call */
uint32_t count = ulTaskNotifyTake(pdTRUE, 0);
printf("%u", count);
AError: function blocks indefinitely
B1
C0
D3
Attempts:
2 left
💡 Hint

Count accumulates with counting notifications.

Predict Output
advanced
2:00remaining
What happens if ulTaskNotifyTake() is called with clear count false on a counting notification?

A task has a notification count of 2. It calls ulTaskNotifyTake(pdFALSE, 0). What is the return value and the new notification count?

FreeRTOS
/* Notification count is 2 before call */
uint32_t count = ulTaskNotifyTake(pdFALSE, 0);
printf("%u", count);
// What is the notification count now?
AReturns 2; notification count resets to 0
BReturns 2; notification count remains 2
CReturns 0; notification count remains 2
DReturns 1; notification count decrements to 1
Attempts:
2 left
💡 Hint

Clear count flag controls if count resets after reading.

Predict Output
advanced
2:00remaining
What is the behavior of ulTaskNotifyTake() with timeout when no notification is pending?

A task calls ulTaskNotifyTake(pdTRUE, 10) but no notification is pending. What happens?

FreeRTOS
uint32_t count = ulTaskNotifyTake(pdTRUE, 10);
printf("%u", count);
AReturns immediately with 0
BReturns immediately with 1
CBlocks up to 10 ticks, then returns 0 if no notification received
DBlocks indefinitely until notification received
Attempts:
2 left
💡 Hint

Timeout controls how long the function waits for notification.

🧠 Conceptual
expert
3:00remaining
How does ulTaskNotifyTake() differ from xTaskNotifyWait() in counting notifications?

Which statement correctly describes the difference between ulTaskNotifyTake() and xTaskNotifyWait() when used for counting notifications?

A<code>ulTaskNotifyTake()</code> returns the current count and optionally clears it; <code>xTaskNotifyWait()</code> waits for a notification and returns a status but does not count.
B<code>ulTaskNotifyTake()</code> decrements the notification count by one per call; <code>xTaskNotifyWait()</code> reads and clears the notification value.
C<code>ulTaskNotifyTake()</code> only works for binary notifications; <code>xTaskNotifyWait()</code> only works for counting notifications.
D<code>ulTaskNotifyTake()</code> blocks indefinitely; <code>xTaskNotifyWait()</code> never blocks.
Attempts:
2 left
💡 Hint

Think about what each function returns and how they handle notification counts.