Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

need help with AIX/pthreads

76 views
Skip to first unread message

Satyendra Dhingra

unread,
Jan 10, 1996, 3:00:00 AM1/10/96
to

Hi,

I need some help with AIX threads. I am trying to use the
pthreads package on 4.1.4.0 system, however the pthreads library
dumps core on the most simple of the calls. Here is the code
for the test case, the program core dumps in the "pthread_attr_init()"
call. Can someone tell me what is going on. Am I using
wrong version of BOS or something else.

---------------------attrtest.c------------------------------

#include <stdio.h>
#include <pthread.h>

main(int argc, char *argv[])
{
pthread_attr_t attr;
int ret = pthread_attr_init(&attr);
return (0);
}


I am using the following line for linking to the pthreads
library


cc -o attrtest.c -o attrtest -lpthreads


thanks in adv for any help,
satyendra
d...@netcom.com

Brian Knoth

unread,
Jan 11, 1996, 3:00:00 AM1/11/96
to
>I am using the following line for linking to the pthreads
>library
>
>
>cc -o attrtest.c -o attrtest -lpthreads
>
>
>thanks in adv for any help,
>satyendra

You need to do a little bit more when compiling and linking a MT
program. I assume you are using xlC, so check your configuration
file for proper compiler options for MT, (-D_THREAD_SAFE,
-D_CMA_NOWRAPPERS (don't know if you need this one with 4.x)).

Finally, make sure that you are linking with the reentrant versions of
C library (libc_r), and crt0 (libcrt0_r).

Hope this helps.

Brian.


Drew Csillag

unread,
Jan 11, 1996, 3:00:00 AM1/11/96
to
There are two ways to do fix your problem:
1) call pthread_init() as your first line of code after the decls in main()
2) use xlC_r (I think it calls pthread_init() in the startup code for you)

--
---------------------------------------------------------------------
Drew Csillag dr...@prodigy.com
Prodigy Service 914-448-8187
UNIX and Sendmail Guru programmer/analyst
---------------------------------------------------------------------


William E. Hannon Jr.

unread,
Jan 12, 1996, 3:00:00 AM1/12/96
to
"Drew" == Drew Csillag <acsi...@maildev.prodigy.com> writes:
In article <4d35hf$2g...@usenetp1.news.prodigy.com> Drew Csillag <acsi...@maildev.prodigy.com> writes:


Drew> There are two ways to do fix your problem:
Drew> 1) call pthread_init() as your first line of code after the decls in main()

Do not call pthread_init() directly .... pthread_init() is called
from __threads_init() which is called from crt0_r.o. __threads_init()
does more than just call pthread_init() so you would be missing the
rest of the threads initialization.

Drew> 2) use xlC_r (I think it calls pthread_init() in the startup code for you)

The only solution is to call one of the *_r compilers ... please
see the /etc/xlC.cfg file for list.
--
William E. Hannon Jr. internet:wha...@austin.ibm.com
DCE Threads Development whannon@austin
Austin, Texas 78758 Department 905S/9132 Phone:(512)838-3238 T/L(678)
'Confidence is what you had, before you understood the situation.' Dr. Dobson

Tony R. Bennett

unread,
Jan 12, 1996, 3:00:00 AM1/12/96
to
In article <daiDKz...@netcom.com>,

Satyendra Dhingra <d...@netcom.com> wrote:
>
>I need some help with AIX threads. I am trying to use the
>pthreads package on 4.1.4.0 system, however the pthreads library
>dumps core on the most simple of the calls. Here is the code
>for the test case, the program core dumps in the "pthread_attr_init()"
>call. Can someone tell me what is going on. Am I using
>wrong version of BOS or something else.
>
stuff deleted

>I am using the following line for linking to the pthreads
>library
>
>
>cc -o attrtest.c -o attrtest -lpthreads
>
>
>satyendra
>d...@netcom.com

The solution on 3.2.5 is to compile with xlc_r instead of cc.
I don't have access to a 4.1.X system but this will give you the
following defaults:
-D_THREAD_SAFE
-D_CMA_NOWRAPPERS_
-D_ANSI_C_SOURCE
-lc_r
-lpthreads

Tony
--
t...@teleport.COM Public Access User --- Not affiliated with Teleport
Public Access UNIX and Internet at (503) 220-1016 (2400-28800, N81)

0 new messages