Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Jun 2010 18:19:15 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Dan Nelson <dnelson@allantgroup.com>
Cc:        freebsd-hackers@freebsd.org, V clav Haisman <v.haisman@sh.cvut.cz>
Subject:   Re: How to get a thread ID?
Message-ID:  <20100603151915.GI83316@deviant.kiev.zoral.com.ua>
In-Reply-To: <20100603144452.GC85961@dan.emsphone.com>
References:  <6e716c850fa84621482b71826dae55d5@shell.sh.cvut.cz> <20100603144452.GC85961@dan.emsphone.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--YA5SKL3iPwSPv+gD
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Jun 03, 2010 at 09:44:52AM -0500, Dan Nelson wrote:
> In the last episode (Jun 03), V??clav Haisman said:
> > is it possible to obtain some sort of a thread ID that identifies a thr=
ead
> > within a process other than pthread_self()?  Something like gettid() on
> > Linux?  Apparently, on FreeBSD the pthread_t is a pointer type and does
> > not identify the thread well enough.  GDB on FreeBSD seems to know about
> > threads and does not seem to use the same ID as is pthread_t.
>=20
> The return value of pthread_self() is a pointer to the (private) "struct
> pthread" for the current thread, and should uniquely identify a thread.  =
Do
> you have a testcase that shows otherwise?  GDB might just enumerate the
> currently active threads starting from 1.

There is thr_self(2) undocumented syscall:
int thr_self(long *id);

--YA5SKL3iPwSPv+gD
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (FreeBSD)

iEYEARECAAYFAkwHx/IACgkQC3+MBN1Mb4jchQCfdER+RknWl4m/1gXPD2chD1Zj
IugAnR+fMYzH4RlXvKHU89VezQICr7Cd
=c3bg
-----END PGP SIGNATURE-----

--YA5SKL3iPwSPv+gD--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100603151915.GI83316>