From owner-freebsd-hackers@FreeBSD.ORG Thu Jun 3 19:16:31 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 70C80106564A for ; Thu, 3 Jun 2010 19:16:31 +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 20EFA8FC21 for ; Thu, 3 Jun 2010 19:16:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by service1.sh.cvut.cz (Postfix) with ESMTP id 6419F12546E; Thu, 3 Jun 2010 21:16:30 +0200 (CEST) X-Spam-Score: -100.665 X-Spam-Level: X-Spam-Status: No, score=-100.665 tagged_above=-255 required=5 tests=[ALL_TRUSTED=-1.44, AWL=0.349, 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 obXoxEfAPTlC; Thu, 3 Jun 2010 21:16:27 +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 22D101252D7; Thu, 3 Jun 2010 21:16:27 +0200 (CEST) Message-ID: <4C07FF8C.1090800@sh.cvut.cz> Date: Thu, 03 Jun 2010 21:16:28 +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> <20100603144452.GC85961@dan.emsphone.com> <20100603151915.GI83316@deviant.kiev.zoral.com.ua> In-Reply-To: <20100603151915.GI83316@deviant.kiev.zoral.com.ua> X-Enigmail-Version: 1.1 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigDF6A748632350A2092CB5F17" 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:16:31 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigDF6A748632350A2092CB5F17 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Kostik Belousov wrote, On 3.6.2010 17:19: > 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 t= hread >>> within a process other than pthread_self()? Something like gettid() = on >>> Linux? Apparently, on FreeBSD the pthread_t is a pointer type and do= es >>> not identify the thread well enough. GDB on FreeBSD seems to know ab= out >>> threads and does not seem to use the same ID as is pthread_t. >> >> The return value of pthread_self() is a pointer to the (private) "stru= ct >> pthread" for the current thread, and should uniquely identify a thread= =2E Do >> you have a testcase that shows otherwise? GDB might just enumerate th= e >> currently active threads starting from 1. >=20 > There is thr_self(2) undocumented syscall: > int thr_self(long *id); Thanks, I'll try it. Is the returned ID the LWP ID that GDB shows? -- VH --------------enigDF6A748632350A2092CB5F17 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/4wACgkQr2CghdezFMlsxwCgg9LhvOwppMs6TawP3QKvyjmF hUgAnjGjMRXzvxEjccqXpAmUYE0Muu/D =qw+X -----END PGP SIGNATURE----- --------------enigDF6A748632350A2092CB5F17--