Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Mar 2005 11:35:52 -0800
From:      "Michael C. Shultz" <ringworm01@gmail.com>
To:        Daniel Eischen <deischen@freebsd.org>, freebsd-hackers@freebsd.org
Subject:   Re: threads question
Message-ID:  <200503151135.53269.ringworm01@gmail.com>
In-Reply-To: <Pine.GSO.4.43.0503151312090.12075-100000@sea.ntplx.net>
References:  <Pine.GSO.4.43.0503151312090.12075-100000@sea.ntplx.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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






Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200503151135.53269.ringworm01>