This is the mail archive of the ecos-discuss@sources.redhat.com 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


Tommy Reynolds <Tommy.Reynolds@MegaCoder.com> writes:

> Uttered Aravind B <arvindb@cranessoftware.com>, spake thus:
> 
> > First thread gives 100 
> > second,third and fourth threads gives 80 .
> > 
> > My problem is in the third thread i have defined short variable.
> > Inspite of it is giving value 80 as 2 and 4 thread.
> > 
> > 2 and 4 thread  is defined as
> > 
> > void procedureB(cyg_addrword_t data)
> > {
> > 	printf("ThreadB %d\n",cyg_thread_measure_stack_usage( handleB));
> > }
> > 
> 
> Why not show us the 3 thread that is giving showing the problem?
> 
> I suspect that the compiler just allocated your short variable into a
> CPU register and not on the stack.  Try using an "int foo[32]" array
> instead.

That is very likely unless the original poster has compiled with all
optimization disabled.

Also, cyg_thread_measure_stack_usage() only gives an approximation. It
scans the stack and uses the first location that is not the
initialization value as the low water mark. Interrupts and context
switches mean that the this will always read more than the thread's
actual use. Alignment of the saved states can also mean that small
changes in thread stack usage are totally obscured.

-- 
Nick Garnett                    eCos Kernel Architect
http://www.ecoscentric.com      The eCos and RedBoot experts


-- 
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]