Quality RTOS & Embedded Software

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


Loading

malloc to separate memory regions

Posted by logicanalyzer on September 16, 2016

I have different classes of memory, (faster, slower, nearby, farther away) and I would like to control where malloc allocates memory. The heap_5 scheme allows the heap to span multiple non-contiguous memory regions but treats them as a single heap.

I need separate heaps and a way to control which one malloc allocates from. Is there a straightforward way to do this, or do I need to write heap_6.c?


malloc to separate memory regions

Posted by rtel on September 16, 2016

I think there might be a change request on this topic already. Basically it is not a straight forward change because it would need a new parameter to the pvPortMalloc() function, and that would have lots of backward compatibility issues. However, you can have more than one memory allocator in your application - so the FreeRTOS code would call the 'standard' pvPortMalloc(), and your application can call whichever memory allocation function is most appropriate for the memory being allocated.


malloc to separate memory regions

Posted by dumarjo on September 16, 2016

Hi,

This is how we do it.

Jonathan

Le 16/09/2016 à 14:20, Real Time Engineers ltd. a écrit : > > I think there might be a change request on this topic already. > Basically it is not a straight forward change because it would need a > new parameter to the pvPortMalloc() function, and that would have lots > of backward compatibility issues. However, you can have more than one > memory allocator in your application - so the FreeRTOS code would call > the 'standard' pvPortMalloc(), and your application can call whichever > memory allocation function is most appropriate for the memory being > allocated. > > ------------------------------------------------------------------------ > > malloc to separate memory regions > https://sourceforge.net/p/freertos/discussion/382005/thread/65d41896/?limit=25#c823 > > ------------------------------------------------------------------------ > > Sent from sourceforge.net because you indicated interest in > https://sourceforge.net/p/freertos/discussion/382005/ > > To unsubscribe from further messages, please visit > https://sourceforge.net/auth/subscriptions/ >


malloc to separate memory regions

Posted by elmood on May 19, 2018

Has there been any change in the way memory management works since this thread was started? I'm new to FreeRTOS and in reading the docs it states: "Using two heap implementations simultaneously permits task stacks and other RTOS objects to be placed in fast internal RAM, and application data to be placed in slower external RAM. " but then later (regarding the five heap implementations) it states: "Exactly one of these source files should be included in a project at a time"

That seems a bit contradictory. I guess this raises two different questions:

  • Can you define which heap region will be used when making a call to pvPortMalloc()? I have SRAM and SDRAM (slower) which I'd like to use for different purposes as the example suggests.

    • Can you actually use two implementations as the first quote suggests? This seems like less of a concern but I'm still confused by the wording.

An actual example, or more clarification on the documentation page would be helpful. Overall the docs are very good, but I want to make sure I understand this before jumping into my project.


malloc to separate memory regions

Posted by richard_damon on May 19, 2018

You can edit the name of the functions in one of the version of the heap files, and then you can include both. That is one of the big advantages of it being provided in source format.


malloc to separate memory regions

Posted by rtel on May 20, 2018

Yes - and I suspect the quoted text is basically saying this in that RTOS code (internally) can call pvPortMalloc() and application code can call malloc() directly (with all the normal thread safety, etc., caveats around that) so the RTOS objects come from a different heap to everything else.


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


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

Latest News

Version 10.1.0 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.


Careers

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

Renesas

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