sparc stack and heap

Joel Sherrill joel.sherrill at oarcorp.com
Tue Jul 25 12:06:12 UTC 2006


Aleix Conchillo Flaqué wrote:

> Hi,
>
> this is probably a basic question, but I've been looking at the code  
> and I don't see it.
>
> I was trying to see how the stack and heap works in RTEMS as we need  
> to define a memory mapping for our application.
>
> Looking at the code, I see that the libc memory manager is  
> initialised in c/src/lib/libbsp/sparc/shared/bspstart.c in the  
> bsp_pretasking_hook function. There, the heap_start is initialised  
> (using the "end" variable that comes from the linkcmds file), also  
> the heap_size is initialised. To initialise it, a STACK_SIZE define  
> is used, the value is 16*1024. Also, the CPU_STACK_MINIMUM_SIZE for  
> SPARC is 1024*4, which if I have understood it right, is the stack  
> size for a single task.
>
STACK_SIZE in linkcmds looks the size of the initial stack used for 
system initialization in that BSP.
Do you see symbols near it in start.S used to set the stack pointer?

The application usually uses confdefs.h to specify the RTEMS resources 
needed.  confdefs.h calculates
the required amount of workspace. If you configure 10 tasks, then it 
calculates you need 40K for corresponding
task stacks.  This is from the ticker sample:

#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER

#define CONFIGURE_MAXIMUM_TASKS             4
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_EXTRA_TASK_STACKS         (3 * RTEMS_MINIMUM_STACK_SIZE)

#include <rtems/confdefs.h>

It says that the application wants a maximum of 4 Classic API tasks and 
3 of those use stacks of
twice the minimum.

> Does this mean that we only can have 4 tasks? If we have more tasks,  
> could the end of the heap be overwritten?
>
No.  You can have as many as you have RAM.  See 
libbsp/sparc/shared/bspstart.c which
tries to give the required memory above the heap to the RTEMS Workspace.

> I'm probably missing something. Thanks in advance.
>
> Cheers,
>
> aleix
>
>
>
>




More information about the users mailing list