[En-Nut-Discussion] How much memory is still available in the stack of a thread?
Brett Abbott
Brett.Abbott at digital-telemetry.com
Sun Jun 24 10:56:23 CEST 2007
Hi Rodrigue
I found the best way to achieve this was to clear memory rather than
just allocate it when a thread is created. ((Use AllocClear - you will
need to change the library)). This then allows you to more reliably
scan the allocated memory to determine how much of it has been used. If
you dont use AllocClear then after a period of time, or following a
reboot/reset, you will start to get random results as memory is only
cleared on power cycle.
Cheers
Brett
Rodrigue wrote:
> Thank you
>
>
> Ovidiu-2 wrote:
>
>> On 4/25/07, Rodrigue <rodrigue.roland at gmail.com> wrote:
>>
>>> It was just to propose a way to optimize the stack space consumed by a
>>> thread...
>>> Thank you for the link, some informations were very instructive!
>>>
>>
>> Please, could you tell me what represents the variable var in the
>> following
>>
>>> operation:
>>> u_int var = (uptr_t) runningThread->td_sp - (uptr_t)
>>>
>> http://www.ethernut.de/en/documents/ntn-2_events.html might help (look for
>> "td_sp" in the first picture!)
>>
>> Harald Kipp wrote:
>>
>>>> Each thread has its own stack space, taken from the global heap.
>>>> http://www.vs.inf.ethz.ch/edu/wsn/tut/ch4-5.pdf
>>>>
>>>> Why do you need to know the available stack space of a single thread?
>>>> Just asking, because I assume that things are more complex than you are
>>>> possibly aware off.
>>>>
>>>> Harald
>>>>
>>>> Rodrigue schrieb:
>>>>
>>>>> I'm not sure but may be by using the variable runningThread:
>>>>> u_int avaiblememory = (uptr_t) runningThread->td_sp - (uptr_t)
>>>>> runningThread->td_memory;
>>>>>
>>>>> with uptr_t td_sp; /*!< \brief Stack pointer. */
>>>>> u_char *td_memory; /*!< \brief Pointer to heap memory
>>>>>
>>> used
>>>
>>>>> for
>>>>> stack. */
>>>>>
>>>>> Does each thread has is own heap memory? I tought that it was global
>>>>>
>>> and
>>>
>>>>> located at the end of the external memory growing downwards...
>>>>>
>>>>>
>>>>>
>>>> _______________________________________________
>>>> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>>>
>>>>
>>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-much-memory-is-still-available-in-the-stack-of-a-thread--tf3639143.html#a10178771
>>> Sent from the MicroControllers - Ethernut mailing list archive at
>>> Nabble.com.
>>>
>>> _______________________________________________
>>> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>>
>>>
>> _______________________________________________
>> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>
>>
>>
>
>
--
-----------------------------------------------------------------
Brett Abbott, Managing Director, Digital Telemetry Limited
Email: Brett.Abbott at digital-telemetry.com
PO Box 24 036 Manners Street, Wellington, New Zealand
Phone +64 (4) 462-3439 Mobile +64 (21) 656-144
------------------- Commercial in confidence --------------------
More information about the En-Nut-Discussion
mailing list