public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Monitoring stack usage
@ 2013-03-06 16:29 Greg Dyer
  2013-03-06 22:26 ` [ECOS] " John Dallaway
  0 siblings, 1 reply; 2+ messages in thread
From: Greg Dyer @ 2013-03-06 16:29 UTC (permalink / raw)
  To: ecos-discuss

Hello,

I am running an embedded environment using multiple threads in eCos, a
main thread and a logging thread. I've been testing stack usages vs
different stack sizes in the logging thread because I had suspected that
a stack overflow could be occurring in the logging thread causing it to
lock up. I enabled CYGFUN_KERNEL_THREADS_STACK_MEASUREMENT and started
printing the values from cyg_thread_measure_stack_usage as well as the
value from threadInfo.stack_used. 
The value from cyg_thread_measure_stack_usage and threadInfo.stack_used
are always identical. 

My testing:
Stack size of 4096 bytes. The usage got up to 3528 bytes (according to
cyg_thread_measure_stack_usage) 
Stack size of 10240 bytes. The usage got up to 3528 bytes (according to
cyg_thread_measure_stack_usage) 
Stack size of 20480 bytes. The usage got up to 5488 bytes (according to
cyg_thread_measure_stack_usage) 
I was hoping to see with the 10k stack size the usage growing above 4k.
In both the 4k and 10k stack sizes, the logging thread locked up. The
20k stack did not lock up.

I changed a few config parameters and ran the same code as the above
test (except for changing stack sizes) and found some strange results:
Stack size of 4096 bytes. The usage got up to 4096 bytes (according to
cyg_thread_measure_stack_usage) 
Stack size of 10240 bytes. The usage got up to 9820 bytes (according to
cyg_thread_measure_stack_usage) 
Stack size of 20480 bytes. The usage got up to 20208 bytes (according to
cyg_thread_measure_stack_usage) 
Stack size of 102400 bytes. The usage got up to 87350 bytes (according
to cyg_thread_measure_stack_usage) 
It seems that usage tracks fairly close to what the given stack size.
Only the 4k stack size locked up in this test.

Is there a reason that my stack usage could be growing so high in my
second test? The compiled code is identical, only some a few parameters
are changed in my running code. I was expecting to see my stack usage
possibly go above the 4k mark but not continue to grow with my stack
size. Is there a better way I can monitor stack usage to detect an
overflow so I can appropriately set a better stack size?

Thanks,
Greg

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-03-06 22:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-06 16:29 [ECOS] Monitoring stack usage Greg Dyer
2013-03-06 22:26 ` [ECOS] " John Dallaway

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).