threads question

Peter Schuller peter.schuller at infidyne.com
Wed Mar 16 13:33:17 PST 2005


>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 <peter.schuller at infidyne.com>'
Key retrieval: Send an E-Mail to getpgpkey at scode.org
E-Mail: peter.schuller at infidyne.com Web: http://www.scode.org



More information about the freebsd-hackers mailing list