Date: Mon, 7 Feb 2000 13:31:24 -0500 (EST) From: Antoine Beaupre <beaupran@IRO.UMontreal.CA> To: Alfred Perlstein <bright@wintelcom.net> Cc: Freebsd Questions Mailing list <freebsd-questions@FreeBSD.ORG> Subject: Re: PThreads Message-ID: <14495.3964.506494.63679@blc11.IRO.UMontreal.CA> References: <14494.21789.847287.358066@anarcat.dyndns.org> <20000207101438.Y25520@fw.wintelcom.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <beaupran@iro.umontreal.ca> [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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?14495.3964.506494.63679>