Challenge - 5 Problems
Queue Set Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediateOutput of xQueueSelectFromSet when multiple queues have data
Given two queues added to a queue set, both containing data, what does
xQueueSelectFromSet return?FreeRTOS
QueueSetHandle_t xQueueSet = xQueueCreateSet(10); QueueHandle_t xQueue1 = xQueueCreate(5, sizeof(int)); QueueHandle_t xQueue2 = xQueueCreate(5, sizeof(int)); xQueueAddToSet(xQueue1, xQueueSet); xQueueAddToSet(xQueue2, xQueueSet); int val = 42; xQueueSend(xQueue1, &val, 0); xQueueSend(xQueue2, &val, 0); QueueHandle_t xReadyQueue = xQueueSelectFromSet(xQueueSet, 0);
Attempts:
2 left
💡 Hint
Think about how FreeRTOS handles multiple ready queues in a queue set.
✗ Incorrect
When multiple queues in a queue set have data, xQueueSelectFromSet returns one of the ready queues. The selection is not guaranteed to be in any specific order.
🧠 Conceptual
intermediatePurpose of a Queue Set in FreeRTOS
What is the main purpose of using a queue set in FreeRTOS?
Attempts:
2 left
💡 Hint
Think about how you can wait on multiple queues at once.
✗ Incorrect
Queue sets allow a task to block on multiple queues or semaphores simultaneously and unblock when any one of them becomes ready.
❓ Troubleshoot
advancedWhy does xQueueSelectFromSet return NULL unexpectedly?
A task calls
xQueueSelectFromSet with a non-zero block time, but it returns NULL immediately. What is a likely cause?Attempts:
2 left
💡 Hint
Check the validity of the queue set handle and initialization.
✗ Incorrect
If the queue set handle is invalid or not created properly, xQueueSelectFromSet may return NULL immediately even if block time is non-zero.
✅ Best Practice
advancedBest practice for adding queues to a queue set
Which is the best practice when adding queues to a queue set in FreeRTOS?
Attempts:
2 left
💡 Hint
Consider when queues should be added relative to task execution.
✗ Incorrect
Queues should be added to the queue set after the set is created but before tasks block on it to avoid race conditions or undefined behavior.
🔀 Workflow
expertCorrect sequence to monitor multiple queues using a queue set
Arrange the steps in the correct order to monitor multiple queues using a queue set in FreeRTOS.
Attempts:
2 left
💡 Hint
Think about creating queues before adding them to a set.
✗ Incorrect
First create individual queues, then create the queue set, add the queues to the set, and finally use xQueueSelectFromSet to wait on them.
