From owner-freebsd-threads@FreeBSD.ORG Fri Jan 28 00:47:08 2005 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 89F8F16A4CE for ; Fri, 28 Jan 2005 00:47:08 +0000 (GMT) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0320943D4C for ; Fri, 28 Jan 2005 00:47:04 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) j0S0l1Ji009471; Thu, 27 Jan 2005 19:47:01 -0500 (EST) Date: Thu, 27 Jan 2005 19:47:01 -0500 (EST) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Medi Montaseri In-Reply-To: <41F987B7.7080308@amcc.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) cc: freebsd-threads@freebsd.org Subject: Re: pthread_t in 5.3 X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Daniel Eischen List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Jan 2005 00:47:08 -0000 On Thu, 27 Jan 2005, Medi Montaseri wrote: > Daniel Eischen wrote: > > >Sorry, what pthread_t is, is not for you to know. It is up to the > >implementation to define it anyway that it wants. And is also why > >there is a pthread_equal() function. > > > >>I'm not interested in the pointer, I'm interested in the numerical > >>thread ID... > > > >There is no such thing as defined by POSIX. > > > >>Now at this point, you'll think all you have to do is to de-reference > >>the pointer. > >>But since 'struct pthrad' is opaque, gdb and myself are clueless to > >>proceed from here. > >>Can someone shed some light on this please... > >> > >> > > > >I think you are trying to do something that is non-standard/portable. > > But on linux, a thread_t is > typedef unsigned long int pthread_t; > I guess the idea was if a file descriptor is a int and a socket is an > int and a process id is an int > then a thread also be an int and people can have an array of those IDs. It doesn't matter what Linux does; it matters what the POSIX standard says. Nothing precludes pthread_t from being an int or long, but you shouldn't rely on it being that way. Even though our pthread_t is an opaque id (pointer), nothing is stopping you from storing them in an array. An array of: pthread_t tids[NUM_THREADS]; works regardless of the whether you are on Linux or FreeBSD. -- DE