From owner-freebsd-questions Mon Feb 7 11: 6:22 2000 Delivered-To: freebsd-questions@freebsd.org Received: from mercure.IRO.UMontreal.CA (mercure.IRO.UMontreal.CA [132.204.24.67]) by builder.freebsd.org (Postfix) with ESMTP id 8334F4490 for ; Mon, 7 Feb 2000 11:06:17 -0800 (PST) Received: from blc11.IRO.UMontreal.CA (IDENT:root@blc11.IRO.UMontreal.CA [132.204.21.34]) by mercure.IRO.UMontreal.CA (8.9.3/8.9.3) with ESMTP id NAA09734; Mon, 7 Feb 2000 13:31:25 -0500 Received: (from beaupran@localhost) by blc11.IRO.UMontreal.CA (8.9.3/8.9.3) id NAA06645; Mon, 7 Feb 2000 13:31:24 -0500 Full-Name: Antoine Beaupre X-Authentication-Warning: blc11.IRO.UMontreal.CA: beaupran set sender to beaupran@IRO.UMontreal.CA using -f From: Antoine Beaupre MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <14495.3964.506494.63679@blc11.IRO.UMontreal.CA> Date: Mon, 7 Feb 2000 13:31:24 -0500 (EST) To: Alfred Perlstein Cc: Freebsd Questions Mailing list Subject: Re: PThreads References: <14494.21789.847287.358066@anarcat.dyndns.org> <20000207101438.Y25520@fw.wintelcom.net> X-Mailer: VM 6.75 under Emacs 20.3.1 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Thanks a lot.. I knew there was something I was missing and I was a little tired. :) Sorry for the noise.. The AnarCat --- Big Brother told Alfred Perlstein to write, at 10:14 of February 7: > * Spidey [000206 21:43] wrote: > Content-Description: message body text > > Hi! > > > > I am currently working on a program that needs pthreads. > > > > Is there some bugs in FBSD implementation of the pthreads? Because I'm > > having serious problems here: > > no there is no bug. > > > The following code, when executed, gives me something really weird: > > [snip...] > > > Is there something I do not understand in pthreads or what??? > > yes, you can't possibly expect readdir() which returns a pointer > to a _static_ structure to be thread safe the way you are using > it. > > if you wanted to fix this, then I would strdup() the d_name in the main > thread then pass it to the slave threads, (don't forget to free() it!) > > basically, you're relying on a race condition that the string in the > dirent isn't over written by successive calls to readdir(), basically > that your slave thread will run to completion before the main thread > loops again doing a readdir() and clobbering your dirent. > > enjoy, > -Alfred -- Si l'image donne l'illusion de savoir C'est que l'adage pretend que pour croire, L'important ne serait que de voir Lofofora To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message