Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


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 ]    [ Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists