Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


how much data will xQueueSend() copy ?

Posted by chaabanemalki on May 19, 2014


I created a Queue with one item, and the item size is 2048 bytes.

I use this queue to pass commands or data to a 3G module. the maximum size that a command can reach is about 256 bytes but for data can reach 2048.

I was wondering if I send 15 bytes in the queue will the xQueueSend() copy 2048 bytes or just 15 bytes ? and the same question for xQueueReceive() ?

Another question is from what I understand and in ordre to use queue. I have to copy the source buffer into the queue when sending, and copy the same data again when receiving the queue. Basically I'll have to use three times 2048 bytes : to pass data from the source buffer in the sending task to the queue and finally to recieve it in the receiving task. It it possible to use only the queue array that i reserved when creating the queue ?

I'm aware of passing pointers rather then actual data, (queue will be :2048 item, sizeof(item) = char) but that require to use global buffer and i'm trying to avoid global variable as much as possible.

any better ideas or help will be much appreciated

how much data will xQueueSend() copy ?

Posted by rtel on May 19, 2014

You do not get the option of how many bytes to copy into or out of a queue other than when you set the size of the queue at the time you call xQueueCreate().

Unless you have lots of RAM and can spare the time it takes to copy the data into and out of the queue I would very much recommend passing the data by reference. You may even be able to do it zero copy all the way through by having a task allocate the buffer (dynamically or from a pre-allocated pool [the pool size could be 1 if the task can wait for a buffer to be available!]), pass it by reference to whichever intermediary tasks there are, with the final task that touches the data passing the buffer to the 3G interface which is then set up to send the data directly from the original buffer. When the data has been sent the buffer is freed (either dynamically or by returning it to a pool of free buffers). This is how the zero copy interface in FreeRTOS+UDP works.

You have probably read it already, but the following link may have ideas: http://www.freertos.org/Embedded-RTOS-Queues.html


how much data will xQueueSend() copy ?

Posted by chaabanemalki on May 21, 2014

Thank you for the informations

[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS v10.2.0 is available for immediate download. MIT licensed, and including RISC-V and ARMv8-M (Cortex-M33) demos.

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Cadence Tensilica Cortes

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers





STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner