Quality RTOS & Embedded Software

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


Single allocation for queues

Posted by hawk777 on February 14, 2014

I was wondering, right now, xQueueGenericCreate calls pvPortMalloc to allocate a Queuet, then calls it again to allocate the storage space for the queue data. If you have a lot of semaphores, this means a lot of calls to pvPortMalloc all asking for one-byte heap blocks, which will waste quite a bit of space on heap metadata! Wouldn’t it be more efficient to pack the Queuet and its data area into a single heap allocation, of size (sizeof(Queuet)+uxQueueLength*uxItemSize+1), and have the data area live immediately after the Queuet in RAM?

Single allocation for queues

Posted by rtel on February 14, 2014

I think this very topic was discussed a few months back, you might find it in the archive somewhere. Yes it is a good idea, but again because the code is so mature and known to be good at the moment there is some reluctance to make changes right now. Ideally it should have been done before the version 8 release candidates were provided for public review, but there is always very limited time and getting the new features out was priority. Again I would request a feature request is logged for this.


Single allocation for queues

Posted by richard_damon on February 14, 2014

In general you can run into alignment problems with adding a data block after a structure like this, unless you use the C99 feature of being able to add a

type array[];

statement to the end of the structure. But since FreeRTOS only adds arrays of char to the end, and uses memmove (which can't have alignment issues) it should be safe.

I am not sure if it would cause problems with porting that change over to SafeRTOS, which I understand doesn't used dynamic allocations for stuff like this (but I suspect it needs a different interface anyway).

Single allocation for queues

Posted by hawk777 on February 16, 2014

OK, I have made a ticket. Thanks for the consideration!

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

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

Latest News

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

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

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

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