RTEMS initializing stack size

Joel Sherrill joel.sherrill at OARcorp.com
Thu Jan 7 13:05:31 UTC 2010


On 01/07/2010 04:56 AM, Leon Pollak wrote:
> Hello, all.
>
> The cpu_supplement.pdf states in para 7.6.2 the following (about BSP):
> - Must set stack pointer (sp or r1) such that a minimum stack size of MINI-
> MUM_STACK_SIZE bytes is provided for the RTEMS initialization sequence.
>
> Now, when I search the RTEMS source tree for MINIMUM_STACK_SIZE, I can not
> find something looking "normal"...:-)
>
> Besides, I found some strange definition:
> ..c/src/lib/libcpu/powerpc/rtems/powerpc/powerpc.h defines
> PPC_MIMMUM_STACK_FRAME_SIZE as PPC_STACK_ALIGNMENT, which is 8 or 16...???
>
>
>    
Did you spell minimum wrong like I did on the first grep? It is
not MIMMUM. :)  Is it that way in the code? <shudder>

#define CPU_STACK_MINIMUM_SIZE          (1024*8)
#define STACK_MINIMUM_SIZE  CPU_STACK_MINIMUM_SIZE

I don't know what version you are using but in at least the CVS
head, that is a "recommended minimum" and you can configure
the minimum that will be used for tasks.

In my experiments, this can make a lot of difference in memory
consumption IF AND ONLY IF you know what you are doing.
My test case went down to ~10K from ~60K on the SPARC and
PowerPC which use 8K stack recommended minimums.

FWIW I don't think you need 8K for RTEMS init unless you have
deep calls or buffers in driver initialization.  Also please look
at how the CVS head code is reserving it.  This has been fine tuned
and made more consistent across BSPs so you can have separate
workspace and C program heap or a single heap for both.

> Just to be precise: I am speaking about the stack area required by RTEMS at
> its initialization phase, before the first context switch.
>
> Thanks ahead for clarifications.
>    

No problem.  It also gave me a chance to point out some areas
that have improved in recent times.

--joel




More information about the users mailing list