This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Stack usage measurement


Szentirmai Gergely wrote:
> Hello
> 
> I had a bad feeling about stack usage (perhaps measurement), and I have
> written a small testcode, to see what's really happening. It came with
> an interesting result. It seems to me, that cyg_thread_info.stack_used
> gives the max used stack size, not the actual. Is that right? According
> to the docs, it should give the current usage.
> 
> The test code is attached, I use arm-elf-gcc, ecos with default packages.
> 
> The result is also attached. I think that even the last stack usage
> should be equal with 144 Bytes.
> 
> Maybe I am wrong... maybe not.

No, you are correct, the value is the maximum used.  Why is this
less useful than the 'current' used?  Stacks aren't reused or
dynamic (they don't grow or shrink), so [IMO] the most useful
measurement is the max size you'll ever need, which is the
measured value [at the time of the measurement, of course]

In addition, every call your code makes to 'diag_printf()'
perturbs the measurement, as it can use a lot of stack itself!
If you want to be very pure about the measurements, save the
stack information in some variables and only print the results
when done, that way 'diag_printf()'s use won't get in the way.

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]