On Sunday, 7 בOctober 2007, Mike Kemelmakher wrote:
> Hi,
>
> The pthread_attr_getstacksize() and pthread_attr_setstacksize()
> functions, respectively, shall get and set the thread _*creation*_
> stacksize attribute in the attr object.
AFAIK, in terms of the pthead *API*, the creation size is the *only* size.
This is because POSIX threads are implemented on many platforms, including
non-Unix, non-MMU ones. That's why there is a standard attribute to set
the stack size, while you don't have such a parameter for fork().
I must admit I didn't know Linux actually had a growing stack threads
and it seems to me that they are a Linux extension --
For the Linux kernel a thread is a task like any other process and can
easily have its stack mem-mapped to some private pages to implement this
feature. Of course other Unices *may* implement it in a similar way.
> What i need is current stack size of a running thread. My problem is
> that i have a thread with constantly growing stack ( i can see it via
> /proc/PID/smaps ).
Unless someone added a linux-specific API for this, you may have to
revert to /proc/PID/smaps parsing :-(
> Thread uses some functions from a proprietary shared library. I need to
> know when the stack size of the mentioned thread reaches RLIMIT_STACK
> so i can safely restart that thread before it crashes.
The wonders of proprietary code. You cannot fix the memory leak so
you have to work around it... nice.
Maybe the way to wrap it would be:
1. Create a watcher thread that would sample /proc/PID/smaps
2. Have this thread restart the problematic thread --
this is of course application specific.
So when this library eventually get fixed, you can knife the ugly code out.
--
Oron Peled Voice/Fax: +972-4-8228492
[EMAIL PROTECTED] http://www.actcom.co.il/~oron
ICQ UIN: 16527398
The most exciting phrase to hear in science, the one that heralds new
discoveries, is not "Eureka!" (I found it!) but "That's funny ..."
-- Isaac Asimov
================================================================To unsubscribe,
send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]