Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: threaded programs report bogus process size ?



On Wed, 30 Sep 2009, Christos Zoulas wrote:

> In article <h9u2f5$qap$1%serpens.de@localhost>,
> Michael van Elst <mlelstv%serpens.de@localhost> wrote:
> >njoly%pasteur.fr@localhost (Nicolas Joly) writes:
> >
> >>I just noticed that threaded processes may report increasing process
> >>size of their life ...
> >
> >libpthread never frees the pthread data structure and associated
> >thread stack when a thread ends but puts it onto a private queue
> >("deadqueue") and reclaims it again when a new thread is created.
> >
> >The reclaim can fail when a new thread is created shortly after
> >an old thread ended because of a race with the kernel. As a result
> >a new thread is allocated.
> >
> >So _some_ leakage is allowed by design.
> >
> >The problem is that the reclaim operation is only tried for the
> >thread that ended last (the top of the "deadqueue"). So in a
> >tight pthread_create/join loop the leaked threads just pile up.
> >
> >To correct this the reclaim operation should loop over the queue
> >and try to reclaim any of the dead threads.
>
> This seems to fix it.

can you get "almost" the same effect without looping by using LIFO for the
deadqueue rather than FIFO? (eg PTQ_INSERT_TAIL() in pthread__reap())

iain




Home | Main Index | Thread Index | Old Index