From owner-freebsd-hackers@FreeBSD.ORG Thu Jun 3 14:44:56 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 D71691065673 for ; Thu, 3 Jun 2010 14:44:56 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from email1.allantgroup.com (email1.emsphone.com [199.67.51.115]) by mx1.freebsd.org (Postfix) with ESMTP id 9D6D88FC15 for ; Thu, 3 Jun 2010 14:44:56 +0000 (UTC) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by email1.allantgroup.com (8.14.0/8.14.0) with ESMTP id o53EirCA017823 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 3 Jun 2010 09:44:53 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (smmsp@localhost [127.0.0.1]) by dan.emsphone.com (8.14.4/8.14.4) with ESMTP id o53EiqLi080474 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 3 Jun 2010 09:44:53 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.4/8.14.3/Submit) id o53EiqLb080473; Thu, 3 Jun 2010 09:44:52 -0500 (CDT) (envelope-from dan) Date: Thu, 3 Jun 2010 09:44:52 -0500 From: Dan Nelson To: V clav Haisman Message-ID: <20100603144452.GC85961@dan.emsphone.com> References: <6e716c850fa84621482b71826dae55d5@shell.sh.cvut.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6e716c850fa84621482b71826dae55d5@shell.sh.cvut.cz> X-OS: FreeBSD 8.0-STABLE User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: clamav-milter 0.96 at email1.allantgroup.com X-Virus-Status: Clean X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2 (email1.allantgroup.com [199.67.51.78]); Thu, 03 Jun 2010 09:44:53 -0500 (CDT) X-Scanned-By: MIMEDefang 2.45 Cc: freebsd-hackers@freebsd.org 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 14:44:56 -0000 In the last episode (Jun 03), Václav Haisman said: > is it possible to obtain some sort of a thread ID that identifies a thread > 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. 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. -- Dan Nelson dnelson@allantgroup.com