From owner-freebsd-hackers@FreeBSD.ORG Thu Jun 3 19:55:23 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 41F3F1065672 for ; Thu, 3 Jun 2010 19:55:23 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from mail-ww0-f54.google.com (mail-ww0-f54.google.com [74.125.82.54]) by mx1.freebsd.org (Postfix) with ESMTP id C9B3E8FC15 for ; Thu, 3 Jun 2010 19:55:22 +0000 (UTC) Received: by wwb22 with SMTP id 22so508088wwb.13 for ; Thu, 03 Jun 2010 12:55:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=2TK1KCtbY2qg1ngXJjxScS2NGxevz+gXRYPALeGXK+k=; b=V2DwvFPrtTdplrFEbzXV9LyrSlAdzpEkFuQwgSi444OpLyNMTd8kMiz/4NRmwqJ61Z 9AfmKJL0r+IZmCa7pSHDnuKhSqxBTOFyGOQEG+B9JzkiUKRQBRbywfAphAJVcclb1i44 KN6KeIVKy/8s3bjjsp1ceKuiJ3mfAtvNMGFa4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=CbEOo2dA1Dk/LjvrHrHEDnnDG6w+PpL2L+7wRkdqAfpC/jvUy3BaaGS9iXrsmJ88ZD H1jDIvmxvqBRpDuHne2AWkjDY3VGvumt99AamILZz4/Xa8ee8VJjA7IvMQymwtDw0iPj FvknyfJINSsJnX2YM6CGOyOAX675immobAs78= MIME-Version: 1.0 Received: by 10.216.187.131 with SMTP id y3mr1574725wem.34.1275594921712; Thu, 03 Jun 2010 12:55:21 -0700 (PDT) Received: by 10.216.51.78 with HTTP; Thu, 3 Jun 2010 12:55:21 -0700 (PDT) In-Reply-To: <4C07FF8C.1090800@sh.cvut.cz> References: <6e716c850fa84621482b71826dae55d5@shell.sh.cvut.cz> <20100603144452.GC85961@dan.emsphone.com> <20100603151915.GI83316@deviant.kiev.zoral.com.ua> <4C07FF8C.1090800@sh.cvut.cz> Date: Thu, 3 Jun 2010 23:55:21 +0400 Message-ID: From: pluknet To: =?ISO-8859-1?Q?V=E1clav_Haisman?= Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 19:55:23 -0000 2010/6/3 V=E1clav Haisman : > 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 th= read >>>> within a process other than pthread_self()? =A0Something like gettid()= on >>>> Linux? =A0Apparently, on FreeBSD the pthread_t is a pointer type and d= oes >>>> not identify the thread well enough. =A0GDB on FreeBSD seems to know a= bout >>>> 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) "struc= t >>> pthread" for the current thread, and should uniquely identify a thread.= =A0Do >>> you have a testcase that shows otherwise? =A0GDB might just enumerate t= he >>> currently active threads starting from 1. >> >> 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? > thr_self() does its work as well as ddb and procstat do: using td->td_tid. --=20 wbr, pluknet