0
0
FreeRTOSprogramming~20 mins

Task notification vs queue performance in FreeRTOS - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
FreeRTOS Task Communication Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Task Notification vs Queue: Which is faster?

Consider two FreeRTOS tasks communicating data. One uses a task notification to send a single integer value, the other uses a queue to send the same integer. What is the expected difference in performance?

Given the code snippets below, which output best describes the timing results?

FreeRTOS
/* Task Notification example */
uint32_t value = 42;
xTaskNotify(taskHandle, value, eSetValueWithOverwrite);

/* Queue example */
uint32_t value = 42;
xQueueSend(queueHandle, &value, 0);
ATask notification is faster because it uses direct-to-task signaling with minimal overhead, while queues involve copying data and managing queue structures.
BQueue is faster because it supports multiple items and task notifications are limited to one value, causing delays.
CBoth have the same performance since both use interrupts internally to signal tasks.
DTask notification is slower because it requires more CPU cycles to manage the notification bits compared to queues.
Attempts:
2 left
💡 Hint

Think about how much data copying and synchronization each method requires.

🧠 Conceptual
intermediate
1:30remaining
When to prefer task notifications over queues?

Which scenario best fits the use of task notifications instead of queues in FreeRTOS?

AWhen sending large amounts of data between tasks frequently.
BWhen tasks require guaranteed message order and buffering of multiple messages.
CWhen multiple tasks need to receive the same message simultaneously.
DWhen signaling a task with a simple event or a single integer value without data buffering needs.
Attempts:
2 left
💡 Hint

Task notifications are lightweight and limited in data size.

Predict Output
advanced
2:00remaining
Output of task notification value after multiple sends

Given the following FreeRTOS code snippet, what is the value received by the task after two notifications?

FreeRTOS
uint32_t ulValue;

// Task waits for notification and reads value
xTaskNotifyWait(0x00, 0xffffffff, &ulValue, portMAX_DELAY);

// Elsewhere in code:
xTaskNotify(taskHandle, 5, eSetValueWithOverwrite);
xTaskNotify(taskHandle, 3, eSetValueWithOverwrite);
A0
B5
C3
D8
Attempts:
2 left
💡 Hint

Check how eSetValueWithOverwrite affects the notification value.

Predict Output
advanced
2:00remaining
Queue length after multiple sends and receives

What is the length of the queue after the following operations?

FreeRTOS
QueueHandle_t queue = xQueueCreate(3, sizeof(int));
int val = 10;
xQueueSend(queue, &val, 0);
val = 20;
xQueueSend(queue, &val, 0);
int received;
xQueueReceive(queue, &received, 0);
xQueueSend(queue, &val, 0);
A3
B2
C0
D1
Attempts:
2 left
💡 Hint

Count how many items are sent and received.

🧠 Conceptual
expert
2:30remaining
Why might task notifications be unsuitable for complex data transfer?

Which is the main reason task notifications are not recommended for transferring complex or large data between tasks?

ATask notifications can only send a 32-bit value and do not support buffering multiple messages.
BTask notifications require dynamic memory allocation which is slow for large data.
CTask notifications block the scheduler causing delays in other tasks.
DTask notifications automatically copy data which increases CPU usage.
Attempts:
2 left
💡 Hint

Think about the size and buffering capabilities of task notifications.