FreeRTOS queues store items by value: xQueueSend copies the item's bytes into the queue's internal storage, and xQueueReceive copies them out into the receiver's variable. This has two nice consequences, the sender can immediately reuse or let go of its local copy because the queue owns an independent copy, and it's even safe to send a stack-local variable because it's copied before the sending function returns (unlike passing a raw pointer to a local, which would dangle). The cost is that copying large items is expensive in both CPU time and queue RAM (the queue must reserve depth × item-size bytes). So for large payloads you instead send a pointer to the data, the queue then only copies the pointer (a few bytes), but this shifts the burden to you: you must define ownership explicitly, namely who allocated the buffer, who frees or returns it, and the guarantee that the buffer outlives the transfer and isn't mutated by the sender after handoff. A common safe pattern is a pool allocator: the producer allocates a block from a fixed pool, fills it, sends the pointer, and the consumer returns the block to the pool when done. So: small messages by value (simple and safe), large messages by pointer with a clear ownership protocol.
RTOS & Real-Time Concepts · Interview question
What are the copy semantics of a FreeRTOS queue, and when do you send a pointer instead?
A strong answer
What a weak answer sounds like
You know the answer. Do you know what gets you dinged?
Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.
From the lesson
Queues & Inter-Task Communication
Passing data between tasks safely: a kernel queue is a thread-safe blocking FIFO (copy-by-value), the RTOS producer/consumer pattern that replaces shared-global-plus-mutex with message passing.