freertos (and atmega32) memory allocation

zvonko69 wrote on Saturday, May 15, 2010:

can anyone tell me where all the data is actually allocated/stored in ram, i.e. what goes where ,
for example , where are the variables created and initialised in task located in ram , do they end up in
task stack area or what, is there a some sort of tutorial on this sort of thing ?
what about variables created in main() ? what about system stack area etc…
please dont tell me to read compiler/linker manuals or read convoluted source code, :slight_smile:
im a beginner just trying to get a big picture before diving into detailed stuff.
so links  to explanations of these sort of questions related to freertos
would be much appreciated.

thank you all

richard_damon wrote on Saturday, May 15, 2010:

It somewhat depends on the machine/compiler, but in general “static” and “global” variables, are allocated in one part of memory together, and “automatic” variables (those declared inside a function, including main or tasks), are allocated on the "stack:, For automatic variables in a task, or functions called by a task, these are stored in the task’s stack, which depending on which version of “heap” you are using, will either be from an array in the static memory allocated in heap1.c or heap2.c, or if you are using heap3.c, will be within the program heap. Automatic variable from main, will be in the main stack (which will be what the compiler/linker will think is “stack”.

I’m afraid that if you need more details, you are going to need to read the manuals. That is where the details will be described. Normally you don’t really need to know about this sort of details though.

zvonko69 wrote on Saturday, May 15, 2010:

hi richard thanks for your response

what about this main() stack, in relation to freertos, where is this stack actually located in ram,
how do you recover this main() stack area if it is not used up completely (this is mentioned on freertos site somewhere). ?

i was just looking at ram memory with freertos running on atmega32 & two tasks with  simulator software and noticed that
an automatic variable , char *, i.e. pointer to string, initialised before task for loop is not within task stack area, but somwhere near the beginning of ram, i.e. i guess in the are reserved for global stuff ? maybe the pointer to string itself is within the task stack ?

how would you go about finding answers to these sort of detailed questions ?
what compiler output files would tell me this information , im using avr-gcc ?


sotd wrote on Saturday, May 15, 2010:

how would you go about finding answers to these sort of detailed questions ?

Look at the linker script. You tell it where to put things, not the other way round.