Bird
0
0

What is wrong with this FreeRTOS queue usage?

medium📝 Debug Q7 of 15
FreeRTOS - Task Notifications
What is wrong with this FreeRTOS queue usage?
QueueHandle_t queue = xQueueCreate(1, sizeof(uint32_t));
uint32_t data = 100;
xQueueSend(queue, &data, 0);
uint32_t received;
xQueueReceive(queue, &received, 0);
printf("%lu\n", received);
AData type mismatch in xQueueCreate
BQueue size is too small for one item
CxQueueSend and xQueueReceive use zero block time causing possible failure
DMissing queue deletion after use
Step-by-Step Solution
Solution:
  1. Step 1: Analyze block time usage

    Using zero block time means send or receive may fail if queue is full or empty.
  2. Step 2: Check for error handling

    No check is done for success of send or receive, so data may not be sent or received.
  3. Final Answer:

    Zero block time may cause send or receive to fail silently. -> Option C
  4. Quick Check:

    Always check return values when using zero block time [OK]
Quick Trick: Check return values when using zero block time in queues [OK]
Common Mistakes:
  • Ignoring return values of xQueueSend/xQueueReceive
  • Assuming zero block time guarantees success
  • Confusing queue size with data size

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes