Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Jun 2010 09:44:52 -0500
From:      Dan Nelson <dnelson@allantgroup.com>
To:        V clav Haisman <v.haisman@sh.cvut.cz>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: How to get a thread ID?
Message-ID:  <20100603144452.GC85961@dan.emsphone.com>
In-Reply-To: <6e716c850fa84621482b71826dae55d5@shell.sh.cvut.cz>
References:  <6e716c850fa84621482b71826dae55d5@shell.sh.cvut.cz>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100603144452.GC85961>