From owner-freebsd-hackers@FreeBSD.ORG Thu Jun 3 19:15:27 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CE526106564A for ; Thu, 3 Jun 2010 19:15:27 +0000 (UTC) (envelope-from v.haisman@sh.cvut.cz) Received: from service1.sh.cvut.cz (service1.sh.cvut.cz [IPv6:2001:718:2::214]) by mx1.freebsd.org (Postfix) with ESMTP id 26DB68FC15 for ; Thu, 3 Jun 2010 19:15:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by service1.sh.cvut.cz (Postfix) with ESMTP id 6A87E1252D7; Thu, 3 Jun 2010 21:15:26 +0200 (CEST) X-Spam-Score: -100.63 X-Spam-Level: X-Spam-Status: No, score=-100.63 tagged_above=-255 required=5 tests=[ALL_TRUSTED=-1.44, AWL=0.384, CRM114_HAM_00=, RATWARE_GECKO_BUILD=1.426, SMTPAUTH_SHDOMAIN=-100] Received: from service1.sh.cvut.cz ([127.0.0.1]) by localhost (service1.sh.cvut.cz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ebbZ2cXuz54T; Thu, 3 Jun 2010 21:15:22 +0200 (CEST) Received: from [10.0.0.1] (13.101.broadband5.iol.cz [88.100.101.13]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: v.haisman@sh.cvut.cz) by service1.sh.cvut.cz (Postfix) with ESMTP id A8DE412546E; Thu, 3 Jun 2010 21:15:22 +0200 (CEST) Message-ID: <4C07FF45.5070703@sh.cvut.cz> Date: Thu, 03 Jun 2010 21:15:17 +0200 From: =?UTF-8?B?VsOhY2xhdiBIYWlzbWFu?= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.4) Gecko/20100526 Thunderbird/3.1 MIME-Version: 1.0 To: freebsd-hackers@freebsd.org References: <6e716c850fa84621482b71826dae55d5@shell.sh.cvut.cz> In-Reply-To: X-Enigmail-Version: 1.1 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig314A951EB8F701BE6C665A06" Subject: Re: How to get a thread ID? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jun 2010 19:15:27 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig314A951EB8F701BE6C665A06 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Daniel Eischen wrote, On 3.6.2010 16:51: > On Thu, 3 Jun 2010, V=C3=A1clav Haisman wrote: >=20 >> >> Hi, >> is it possible to obtain some sort of a thread ID that identifies a th= read >> 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 th= reads >> and does not seem to use the same ID as is pthread_t. >=20 > "identifies a thread" well enough for what? pthread_t is suppose > to be opaque. Whether it is an int, pointer, or whatever, it is > implementation-defined and not suppose provide any more information > than available through the standard pthread interfaces. There are > some non-portable interfaces in though. Exactly, pthread_t is opaque and it thus it is only by a chance that I ca= n print its value, it is a pointer on FreeBSD. It could as well be a struct= and then I could not possibly do anything to print the thread identity on scr= een. * 4 Thread 28426ec0 (LWP 100172) 0x0804b9f6 in TestThread::run () As shown above, GDB can show some sort of ID, the LWP bit. How does it ge= t it? Is it possible to get the LWP ID from inside the process without debugging it? --------------enig314A951EB8F701BE6C665A06 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEAREIAAYFAkwH/0wACgkQr2CghdezFMnIPACg3HRywOn0bVrX/U7RcXOBP7A8 dfYAn1L0ytWSeyeuuQiqW9x6QEOssOQM =HBhB -----END PGP SIGNATURE----- --------------enig314A951EB8F701BE6C665A06--