How implement pthread_measure_stack_usage on Linux
- From: nine.lesi@xxxxxxxxx
- Date: Wed, 12 Dec 2007 07:40:30 -0800 (PST)
I am making the migration of an application, from eCos to Linux, and
can't
find a replacement for function pthread_measure_stack_usage.
I have found some ideas but can't resolve my problem.
The first
http://groups.google.com/group/comp.programming.threads/browse_thread/thread/dd47b2d45c62909e/1a065171eab1a575?lnk=gst&q=stack+usage#1a065171eab1a575
give two functions, the thr_stksegment to get base stack pointer and
the
function getcontext to get top stack pointer, but I can't find
function
thr_stksegment on linux includes ( grep ".*thr_stk.*" /usr/include/ -
R).
Other solution was
http://groups.google.com/group/comp.os.linux.development.apps/browse_thread/thread/da68b2ed4493d7b6/a9e5586726639754?lnk=gst&q=stack+usage#a9e5586726639754,
using something like this :
-- code --
char* stack_base = NULL;
int main()
{
char x;
stack_base = &x;
printf("Size : %d\n",getStackSize());
}
int getStatckSize()
{
char x,
*xx = &x;
return stack_base - xx;
}
-- end code --
But I can't interpret the values returned, for example the value 116,
are
bits, bytes ???
Another solution, or at least appears to be is the struct rusage on
/usr/include/bits/resource.h, that have the field ru_isrss :
/* Amount of stack memory used (kilobyte-seconds). */
long int ru_isrss;
But why kilobyte-seconds ? I want the usage of memory, not a relation
between
the usage and time.
Any idea is welcome, and if you get down here thanks for the patient
of read
the testament :)
Aníbal
(P.S : Sorry for the English)
.
- Follow-Ups:
- Re: How implement pthread_measure_stack_usage on Linux
- From: Steve Watt
- Re: How implement pthread_measure_stack_usage on Linux
- From: Scott Gifford
- Re: How implement pthread_measure_stack_usage on Linux
- From: John Dallman
- Re: How implement pthread_measure_stack_usage on Linux
- Prev by Date: Re: Design Questions on Termination
- Next by Date: Re: How implement pthread_measure_stack_usage on Linux
- Previous by thread: Design Questions on Termination
- Next by thread: Re: How implement pthread_measure_stack_usage on Linux
- Index(es):
Relevant Pages
|