[prev in list] [next in list] [prev in thread] [next in thread]
List: hpux-devtools
Subject: RE: HPUX-DEVTOOLS: mixing threaded and non-threaded code
From: "SAILER,LEE (HP-USA,ex1)" <lee_sailer () hp ! com>
Date: 2001-05-31 20:25:35
[Download RAW message or body]
> Hello -
>
> I would like to find a definitive answer on whether it is
> safe to have a
> library that is compiled with threading enabled, linked with
> other code that
> was compiled without it. Is there a document that has
> information on this?
> The couple manuals I found on threading did not cover this issue.
>
It often works out OK. however, the general answer is that if any library
is multi-threaded then all the rest of the objects must be "thread safe".
the most common case is that programmers are linking to a vendor provided
database library that is multi-threaded, but because the programmer never
actually uses pthread_create(), he or she believes that thread safety is
irrelevant. BZZZT. Wrong. Sorry. Please play again.
I am not the final authority on this issue, but I run across it all the
time.
I can suggest some minimum safety measures.
1. #include <pthread.h> in every source file, preferably first.
2. -DPTHREAD_DRAFT4 if old (DCE/DMA) HP-UX threads are in play.
3. -D_POSIX_C_SOURCE=199506L for all source files. Best is to put it in
master .h files directly.
4. If aCC is in play, there are some more -D's required. The newest aCC
has a +mt option (I think) that turns them all on.
5. Be careful of link order. libc must always come after libpthread (or
libcma). Set LDOPTS=-v to get a verbose link and examine the output
carefully.
6. Use thread safe API's where available, such as getlogin_r() in place of
getlogin()
NOTE: The symptom most often related to thread UNsafety is the occasional
mysterious core dump of a process that otherwise seems to work most the
time. Sound familiar?
_________________________________________________________________
To leave this mailing list, send mail to majordomo@cxx.cup.hp.com
with the message UNSUBSCRIBE hpux-devtools
_________________________________________________________________
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic