Operating System - HP-UX
1833323 Members
3091 Online
110051 Solutions
New Discussion

pthreads_tr linking problem

 
Courtney Brown_1
Occasional Advisor

pthreads_tr linking problem

We are porting a dce application to kernel threads. Funny thing: the code behaves when we link to libpthread_tr.sl; it does not behave when we link to libpthread.sl. More specifically, it will not call the function specified in pthread_once (the first pthread call). Anyone experience anything similar and or have some advice?
2 REPLIES 2
Steven Gillard_2
Honored Contributor

Re: pthreads_tr linking problem

I've never used pthread_once, but my advise is to be careful that you are initialising the once_control object correctly:

static pthread_once_t once_control = PTHREAD_ONCE_INIT;
extern void initialize();

(void)pthread_once(&once_control, initialize);

Make sure multiple threads aren't using different once_control objects, and that they aren't re-initialising the same object before calling pthread_once. Ideally initialise the once_object before creating any threads.

Migrating to kernel threads will always expose those race conditions that you never knew you had :)

Regards,
Steve
Courtney Brown_1
Occasional Advisor

Re: pthreads_tr linking problem

Thank you for the input Steve. I double-checked everything you recommended in your reply and still have the same results. The pthread_once function returns properly, but it does not cause the referenced function to be executed.

I am still confused by the program executing when the tracing version of the pthread library(libpthread_tr) is linked in and not executing with the normal version linked in. I suspect, but have not confirmed yet, that this problem is not restricted to the pthread_once call. It just happens to be the first pthread call made by our program.