From owner-freebsd-threads@FreeBSD.ORG Wed Jun 4 06:52:09 2003 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 9E90037B401 for ; Wed, 4 Jun 2003 06:52:09 -0700 (PDT) Received: from pop015.verizon.net (pop015pub.verizon.net [206.46.170.172]) by mx1.FreeBSD.org (Postfix) with ESMTP id D859F43FA3 for ; Wed, 4 Jun 2003 06:52:08 -0700 (PDT) (envelope-from mtm@identd.net) Received: from kokeb.ambesa.net ([138.88.93.237]) by pop015.verizon.net (InterMail vM.5.01.05.33 201-253-122-126-133-20030313) with ESMTP id <20030604135208.LPAG20810.pop015.verizon.net@kokeb.ambesa.net>; Wed, 4 Jun 2003 08:52:08 -0500 Date: Wed, 4 Jun 2003 09:52:07 -0400 From: Mike Makonnen To: Kern Sibbald In-Reply-To: <1054730325.13630.456.camel@rufus> References: <1054730325.13630.456.camel@rufus> X-Mailer: Sylpheed version 0.8.10 (GTK+ 1.2.10; i386-portbld-freebsd5.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Authentication-Info: Submitted using SMTP AUTH at pop015.verizon.net from [138.88.93.237] at Wed, 4 Jun 2003 08:52:07 -0500 Message-Id: <20030604135208.LPAG20810.pop015.verizon.net@kokeb.ambesa.net> cc: freebsd-threads@freebsd.org Subject: Re: FreeBSD pthread_equal "bug" X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jun 2003 13:52:09 -0000 >From the new linux NPTL: ================= typedef struct __opaque_pthread *pthread_t; int __pthread_equal (thread1, thread2) pthread_t thread1; pthread_t thread2; { return thread1 == thread2; } strong_alias (__pthread_equal, pthread_equal) >From FreeBSD's libc_r implementation: ========================== typedef struct pthread *pthread_t; __weak_reference(_pthread_equal, pthread_equal); int _pthread_equal(pthread_t t1, pthread_t t2) { /* Compare the two thread pointers: */ return (t1 == t2); } In both implementations pthread_t is a pointer to a memory location. So, your inability to reproduce this on Linux is probably an accident and not an intentional feature. If the two threads (i.e. the dead one and the new one point to the same memory location using unique id's is not going to solve the problem because both pointers will be pointing to the same structure (and therefore the same unique id, even though it will be a different id after the second thread is created). The only fool-proof way to do this is to make pthread_t a proper structure containing a unique id and a pointer to a thread structure, but that would mean passing a structure on the stack (which is not necessarily bad in itself, but means someone would have to go through all the threads libraries and modify appropriately). On the other hand I may be mistaken and there may be an easy way to achieve this :-) Cheers. -- Mike Makonnen | GPG-KEY: http://www.identd.net/~mtm/mtm.asc mtm@identd.net | D228 1A6F C64E 120A A1C9 A3AA DAE1 E2AF DBCC 68B9 mtm@FreeBSD.Org| FreeBSD - The Power To Serve