How implement pthread_measure_stack_usage on Linux



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)

.



Relevant Pages

  • Re: Why is the file /bin/false so large?
    ... usage (int status) ... fputs (VERSION_OPTION_DESCRIPTION, stdout); ... main (int argc, char **argv) ...
    (Ubuntu)
  • Re: hex to int
    ... int main(int argc, char **argv) ... puts("hex usage error"); ...
    (comp.lang.c)
  • Re: hex to int
    ... int main(int argc, char **argv) ... puts("hex usage error"); ...
    (comp.lang.c)
  • Re: hex to int
    ... int main(int argc, char **argv) ... puts("hex usage error"); ...
    (comp.lang.c)
  • Re: [MFC REQUEST] Filename completion in sh(1)
    ... * This code is derived from software contributed to The NetBSD Foundation ... +static const char * ... +static int ... void ckfree; ...
    (freebsd-current)