Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
823 Views

freertos - memory used

Hi everybody! 

 

I have installed freeRTOS operating system into a cyclone iii. With this operating system it is possible to assign a piece of the RAM memory for each task. I want to know how much RAM is necessary for run freertos and which size must have the stack.  

 

In the declaration of a new task is necessary to use a parameter configMINIMAL_STACK_SIZE, you have tu sum all the possible tasks for calculate the stack size? 

 

Many thanks, 

 

ifdm
0 Kudos
3 Replies
Altera_Forum
Honored Contributor I
32 Views

How long is a piece of string? 

 

The amount of stack depends on the depth of subroutine calls and the amount of stack space each uses (for local variables etc). 

It is possible to do static analysis of the object code (or compiler 'asm' listing), but that is difficult if there are potentially recursive functions or indirect calls. 

 

Typically any on-stack buffers dominate. 

 

Unfortunately the 'try it and see' approach doesn't necessarily work either - as the limit could well be within the error logging for some uncommon failure and/or require an interrupt to occurr when the stack use is already high (one reason for switching stacks on interrupt).
Altera_Forum
Honored Contributor I
32 Views

although is not possible to calculate size, it can be assumed that each context switch (when the scheduler assign the time to another task ) also the stack content change?  

 

And if this is true, all the stack assigned to a task is copied into another part of the RAM?
Altera_Forum
Honored Contributor I
32 Views

Basically during a context switch an OS saves the stack pointer into the current process's control block (PCB). It then loads the stack pointer of the new process and excutes a 'return' instruction. 

Other registers might be saved in the PCB or on stack, the callee saved registers need not be saved - but may be saved to avoid leaking values from other contexts.