threads question
Michael C. Shultz
ringworm01 at gmail.com
Tue Mar 15 11:35:57 PST 2005
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 at 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
More information about the freebsd-hackers
mailing list