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




Loading

portBYTE_ALIGNMENT in heap_4.c

Posted by 386 on July 5, 2013
I am wondering why is necessary to align PortMalloc blocks? My MCU is Cortex M3 / STM with 128K RAM. I have large number of small objects and lose 10-15K only for the alignments. Is there any problem if I modify heap_4.c to align at byte boundary? Probably the memory access may be slower but this is less important than memory size. I read that it is not recommended to modify portBYTE_ALIGNMENT macro because it is used for stack alignment.

RE: portBYTE_ALIGNMENT in heap_4.c

Posted by Richard on July 5, 2013
“I read that it is not recommended to modify portBYTE_ALIGNMENT macro because it is used for stack alignment.”


Then you have answered your own question :o)

You must be allocating a *lot* of blocks to loose 10-15K in alignment padding as the current FreeRTOS release will loose a maximum of 8 bytes per allocation. The next FreeRTOS release does improve the amount of loss so blocks that are 8 byte aligned already don't loose any, meaning the maximum loss per allocation is 7.

Regards.

RE: portBYTE_ALIGNMENT in heap_4.c

Posted by 386 on July 5, 2013
I am parsing XML file. All dynamic data is about 47K (about 1500-2000 small objects). I tested with portBYTE_ALIGNMENT = 2 and the free memory difference at the end was about 7K - the percentage (7 of 47) is not small. Maybe it is a good idea to have heap_5.c for "economical" pvPortMalloc. Also I think it is necessary to implement PortRealloc.

RE: portBYTE_ALIGNMENT in heap_4.c

Posted by Coco on July 22, 2013
Hi, I'm also interested in this topic. Just curious, Is there any specific reason to align the memory for M3 in 8 bytes (is it to resolve some issues)? I realize that the older FreeRTOS sets this value at 4 bytes.

RE: portBYTE_ALIGNMENT in heap_4.c

Posted by Richard on July 22, 2013
Heap_4.c has been updated in FreeRTOS V7.5.0.

“Hi, I'm also interested in this topic. Just curious, Is there any specific reason to align the memory for M3 in 8 bytes (is it to resolve some issues)? I realize that the older FreeRTOS sets this value at 4 bytes. ”


The ARM ABI is to have 8 byte alignment. You probably won't notice any difference unless you start calling library functions that assume 8 byte alignment. The one that shows this up normally is calling printf() with a %f to format a double precision floating point value.

Regards.


[ 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