This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
Re: [PATCH] Add pthread_getname_np, pthread_setname_np
On Feb 24 05:00, Yaakov (Cygwin/X) wrote:
> On Fri, 2012-02-24 at 10:38 +0100, Corinna Vinschen wrote:
> > On Feb 23 21:38, Yaakov (Cygwin/X) wrote:
> > > This patchset adds pthread_getname_np and pthread_setname_np. These
> > > were added to glibc in 2.12[1] and are also present in some form on
> > > NetBSD and several UNIXes. IIUC recent versions of GDB can benefit from
> > > this support.
> >
> > Thanks for your patch, but I don't think it's the whole thing.
> >
> > Consider, if you implement pthread_[gs]etname_np as you did, then you
> > have pthread names which are only available to the process in which
> > the threads are running.
>
> My implementation is based on NetBSD's[1]. So what purpose do these
> functions serve then on that it and the UNIXes? (Serious question.)
See the source of the pthread_setname_np function. There's a call to
the kernel:
thread->pt_name = cp;
(void)_lwp_setname(thread->pt_lid, cp);
_lwp_setname ultimately calls the kernel function sys__lwp_setname in
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/sys_lwp.c?rev=1.53
So the kernel knows the name and the sys__lwp_getname entry point
can be used to fetch the name of a thread in another process. How
exactly this is fetched by which BSD tool, I don't know, but it's
all in the sources :)
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat