malloc to separate memory regions

logicanalyzer wrote on Friday, 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?

rtel wrote on Friday, 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.

dumarjo wrote on Friday, 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
SourceForge.net: Log In to SourceForge.net

To unsubscribe from further messages, please visit
SourceForge.net: Log In to SourceForge.net

elmood wrote on Saturday, 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.

richard_damon wrote on Saturday, 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.

rtel wrote on Sunday, 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.