From owner-freebsd-hackers@FreeBSD.ORG Tue Mar 15 19:35:57 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 42B4616A4CE; Tue, 15 Mar 2005 19:35:57 +0000 (GMT) Received: from vms046pub.verizon.net (vms046pub.verizon.net [206.46.252.46]) by mx1.FreeBSD.org (Postfix) with ESMTP id 14C6843D49; Tue, 15 Mar 2005 19:35:57 +0000 (GMT) (envelope-from ringworm01@gmail.com) Received: from ringworm.mechee.com ([4.27.46.32]) by vms046.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0IDE0011QRRWME31@vms046.mailsrvcs.net>; Tue, 15 Mar 2005 13:35:56 -0600 (CST) Received: by ringworm.mechee.com (Postfix, from userid 1001) id 1C8152CE75B; Tue, 15 Mar 2005 11:35:54 -0800 (PST) Date: Tue, 15 Mar 2005 11:35:52 -0800 From: "Michael C. Shultz" In-reply-to: To: Daniel Eischen , freebsd-hackers@freebsd.org Message-id: <200503151135.53269.ringworm01@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Content-disposition: inline References: User-Agent: KMail/1.7.2 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: Tue, 15 Mar 2005 19:35:57 -0000 On Tuesday 15 March 2005 10:19 am, Daniel Eischen wrote: > On Tue, 15 Mar 2005, Michael C. Shultz wrote: > > Daniel, sorry to bother you again but I ran into something that is > > either a bug or I am missing a vital piece of information > > somewhere. Here is the situation: > > > > 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! > > > > I remember from assembly days that there were some stack tricks to > > be done when making calls to a shared library in order to pass the > > parameters, I forget what they are (been ages since I did assembly > > programming) but anyways it seems like with gcc passing the args > > through the stack to a function in a shared library isn't being > > handled correctly. Am I missing something obvious? > > I don't know. You have to be sure that whatever property > points to stays valid for the life of the thread (or at > least as long as it is used). I have to reply to you through freebsd-hackers@freebsd.org because your blocking verizon's smtp. I just converted everything to static libraries and now pthread_create is working just fine. The answer is probably something like what you just said, scope being lost when making the call to a shared library. Why is it ok going to a static library but not a shared though? In a few days, when there is time, I will write an assembly routine with nasm to use pthread_create and pass my structProperty argument to a shared library with it, this way I can see just exactly what is being passed through the stack. Then hopefully I can find some C/assembly guru who can look at it and teach me how to do it with C. Messing with and examining stacks in C is way beyond my present abilities. (I'm a C newbie) -Mike