Memory Allocation

Top  Previous  Next

Because of the wide variation in memory hardware, different CPU modules and environments may need different methods of allocating the logical areas of a C program to physical memory. This allocation is not done when tasks are created (linked), but is performed by the configurer when the complete application is built. The decisions on how the allocation is to be done are made using the following information:


The design of the board, including such information as the speed and size of the various physical memory blocks, so far as these can be known;

The sizes of the logical areas (including user-defined sections) of all the tasks making up the application;

Explicit requests you make to place certain logical areas in specific physical areas, or at specific memory addresses;

Hints you give about which logical areas of which tasks it would be profitable to optimize, that is, place in fast memory;

The order in which tasks have been placed on the processor: allocation is done in order of placement.

 

On each processor, the configurer maps the logical areas into physical memory in the following order:

1.

logical areas given explicit addresses;

2.

logical areas appearing in OPT statements;

3.

the interrupt vector

4.

the kernel and other system tasks;

5.

remaining logical areas with known sizes;

6.

data areas created by the configurer for task management;

7.

a single STACK, HEAP or DATA area without an explicit size.

 

The configurer always uses fast memory in preference to slow. This means using the internal (on-chip) memory if it is available, and, failing that, the fastest available area of external memory.

 

The configurer is very good at allocating memory and its choices are usually good enough for most applications. You can see how the configurer has allocated memory to your tasks by examining the listing file which you can generate with the -l command option.

 

The next sections describe how you can adjust the memory mapping to improve performance. See also the description of the TASK statement.