From owner-freebsd-hackers@FreeBSD.ORG Wed Mar 16 21:33:17 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2D11A16A4CE for ; Wed, 16 Mar 2005 21:33:17 +0000 (GMT) Received: from mxfep02.bredband.com (mxfep02.bredband.com [195.54.107.73]) by mx1.FreeBSD.org (Postfix) with ESMTP id 23E7043D41 for ; Wed, 16 Mar 2005 21:33:16 +0000 (GMT) (envelope-from scode@scode-whitestar.mine.nu) Received: from scode-whitestar.mine.nu ([83.226.138.147] [83.226.138.147]) by mxfep02.bredband.com with ESMTP <20050316213315.YXQM4482.mxfep02.bredband.com@scode-whitestar.mine.nu>; Wed, 16 Mar 2005 22:33:15 +0100 Received: by scode-whitestar.mine.nu (Postfix, from userid 1001) id B622A17B926; Wed, 16 Mar 2005 22:40:15 +0100 (CET) Date: Wed, 16 Mar 2005 22:40:15 +0100 From: Peter Schuller To: "Michael C. Shultz" Message-ID: <20050316214014.GA88231@scode-whitestar.mine.nu> References: <200503151135.53269.ringworm01@gmail.com> <200503151228.17719.ringworm01@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200503151228.17719.ringworm01@gmail.com> User-Agent: Mutt/1.5.8i cc: freebsd-hackers@freebsd.org cc: Zera William Holladay Subject: Re: threads question X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Mar 2005 21:33:17 -0000 >this works perfectly because I moved MGPMrUpgrade into >the same .c file so it would be a static function: > >structProperty* property; >pthread_t threads[NTHREADS]; >pthread_create( &threads[0], NULL, zzMGPMrUpgrade, property ); >When I use MGPMrUpgrade from a shared library the function runs >yet property isn't being passed! What do you mean by it not being passed? Does your function receive a NULL value for the parameter instead of the pointer? (Assuming no dirty tricks, the function would by definition always be passed *some* value, though it may be NULL.) > Hmmm, should I'll try making "property" global then passing a copy of it > to each thread? I think that will guarantee it stays valid. Since you are asking about makint it global - what is it *now*? It would have to be either global, dynamically allocated, or on the stack. If it's on the stack, things are guaranteed to blow up unless the function in question is guaranteed to not terminate untill all threads are done with the data. What is the property pointer being initialized/set to? If it's dynamically allocated you should not have a problem. And I don't see how static vs. dynamic linking of libraries should matter, but perhaps I am overlooking something. -- / Peter Schuller, InfiDyne Technologies HB PGP userID: 0xE9758B7D or 'Peter Schuller ' Key retrieval: Send an E-Mail to getpgpkey@scode.org E-Mail: peter.schuller@infidyne.com Web: http://www.scode.org