sparc stack and heap

Joel Sherrill joel.sherrill at oarcorp.com
Mon Aug 21 14:34:40 UTC 2006



Yacine EL KOLLI wrote:
> Hello,
>
> AFAIK, CONFIGURE_INIT_STACK_SIZE does only change the stack size of 
> the init task.
> For pthread this is defined by default in:
> cpukit/posix /include/rtems/posix/pthread.h at line 26:
> #define PTHREAD_MINIMUM_STACK_SIZE (STACK_MINIMUM_SIZE * 2)
>
> May be the proper way to modify the pthread default stack size is to 
> specify the stack size when creating the thread or to modify the 
> global variable _POSIX_Threads_Default_attributes ?
>
Don't change the default attributes.  There is a way to use an explicit 
set of pthread attributes and
the stack size is one of those.  You will need to use pthread_attr_init and
pthread_attr_setstacksize.  Then pass the attributes to pthread_create.

Sorry if this is confusing.  I just implemented the API, I didn't design 
it. :)

--joel
> Also you can enable the stack checker (#define STACK_CHECKER_ON in 
> your appllication header)
>
> Hope this help
> Yacine.
>
> Marek Prochazka wrote:
>> Hello,
>>
>> in my application on Leon2, I configure RTEMS to have 
>> CONFIGURE_INIT_STACK_SIZE             (20 * RTEMS_MINIMUM_STACK_SIZE)
>>
>> This gives 81920 bytes for a single task stack. However, if I print 
>> addresses of two variables allocated on stack in two different POSIX 
>> threads (I assume each POSIX thread uses a single RTEMS task), I get 
>> 0x4ffa5e84 and 0x4ffa38c4. This gives only 0x25c0 (9664) bytes 
>> difference, which does not seem right. Am I missing something?
>>
>> We are apparently having problems with not properly controlling stack 
>> size hence in case of more allocation on the stack we perhaps 
>> experience an overflow (random crashes, the fewer automatic 
>> variables, the later a crash occurs). Any hints please? Any 
>> diagnostic tools available?
>>
>> Thanks,
>> Marek Prochazka
>>
>>
>>> -----Original Message-----
>>> From: Joel Sherrill [mailto:joel.sherrill at oarcorp.com] Sent: 25 July 
>>> 2006 15:11
>>> To: Aleix Conchillo Flaqué
>>> Cc: Chris Johns; rtems-users at rtems.com
>>> Subject: Re: sparc stack and heap
>>>
>>> Aleix Conchillo Flaqué wrote:
>>>
>>>
>>>> Thanks for the answer Chris.
>>>>
>>>> I'll need to modify some things from the ERC32 bsp, because 
>>>
>>> I need to 
>>>> keep some data into RAM between reboots, so I'll have to play with  
>>>> heap and workspace addresses.
>>>
>>>
>>> The simplest think to do would be to edit the linkcmds and reserve 
>>> an area after the BSS.  If you
>>> move the "end" symbols to after your reserved block, then it will 
>>> just be ignored by the BSP
>>> when it is carving memory.
>>>
>>> You could do this in an application specific linkcmds and add 
>>> -qnolinkcmds -T myLinkcmds
>>> to the gcc command that links your application.  It would avoid 
>>> otherwise changing the
>>> BSP as installed by RTEMS.
>>>
>>> --joel
>>>
>>>
>>>> Regards,
>>>>
>>>> aleix
>>>>
>>>> On 25 Jul 2006, at 15:23, Chris Johns wrote:
>>>>
>>>>
>>>>> Aleix Conchillo Flaqué wrote:
>>>>>
>>>>>
>>>>>> I'll answer my self, task stacks are allocated in the heap. Right?
>>>>>
>>>>>
>>>>> No the workspace.
>>>>>
>>>>> You need to decided now to the split the memory between the  
>>>>> workspace and the heap. The typical way is to place the 
>>>
>>> workspace  at
>>>>> the top and the heap between the end of .bss and the start of  the 
>>>>> workspace.
>>>>>
>>>>> Regards
>>>>> Chris
>>>>
>>>>
>>
>>
>
>




More information about the users mailing list