Re: RFA [threads]: Thread cache

Michael Snyder
2003-01-14T22:33:15Z

Daniel Jacobowitz wrote:
>
> On Mon, Jan 13, 2003 at 04:04:20PM -0800, Michael Snyder wrote:
> > Daniel Jacobowitz wrote:

> > > For instance, I'd like to know if I
> > > can safely cache the thread handles across resumes; if I could, this
> > > would be much much much much easier to do efficiently. We could get
> > > the thread handle and LWP when the thread is created, and then hold the
> > > thread handle, and optionally hold the LWP. I am pretty sure this is
> > > safe given glibc, but I don't know in general.
> >
> > I think in general not.
>
> Hmm. The Solaris documentation suggests that this is valid; I have no
> way to check whether it actually is, and there is no explicit
> description of the lifetime of a thread handle, but it doesn't describe
> them as being of limited life. It's a handle to "the thread object"
> itself.

Dan,

I passed your question along to Ulrich Drepper, and he says that,
if by "thread handle" you mean the th_unique value, then yes,
those are persistant until the thread exits. If you mean the
td_thrhandle_t value, though, then no, they are not persistant.
They are allocated by libthread-db as needed, then thrown away.