From owner-freebsd-hackers@FreeBSD.ORG Thu Jun 3 15:19:35 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 B0EF51065674 for ; Thu, 3 Jun 2010 15:19:35 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 2AB0B8FC15 for ; Thu, 3 Jun 2010 15:19:34 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id o53FJUKm025767 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 3 Jun 2010 18:19:31 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id o53FJHtF015863; Thu, 3 Jun 2010 18:19:17 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id o53FJFPP015862; Thu, 3 Jun 2010 18:19:15 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 3 Jun 2010 18:19:15 +0300 From: Kostik Belousov To: Dan Nelson Message-ID: <20100603151915.GI83316@deviant.kiev.zoral.com.ua> References: <6e716c850fa84621482b71826dae55d5@shell.sh.cvut.cz> <20100603144452.GC85961@dan.emsphone.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="YA5SKL3iPwSPv+gD" Content-Disposition: inline In-Reply-To: <20100603144452.GC85961@dan.emsphone.com> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-2.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_50, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: freebsd-hackers@freebsd.org, V clav Haisman 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 15:19:35 -0000 --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--