Alex Shnitman <[EMAIL PROTECTED]> writes:
On Sun, 2003-07-13 at 10:49, Gilad Ben-Yossef wrote:
Can you please post the link command used to generate the binary? did you remember to lni libpthread? because if you didn't you're using the standart fork/exec instead of the thread aware ones from libpthread and this explains what you're seeing.
Gilad, thanks! I was using -lrt instead of -lpthread. -lrt includes the timer_* routines, and it also links to libpthread, but apparently overrides the functions with some other non-working versions. -lpthread works fine.
I'd like to understand the effect if someone is kind enough to provide an explanation (or confirm my guess below).
On my RH7.3 (glibc-2.2.5-43, gcc-2.96-113, kernel 2.4.20-18.7) librt has only undefined references to pthread_create. FWIW the results of /pth created with
gcc -o pth pth.c -lpthread
and
gcc -o pth pth.c -lrt
where pth.c contains the code from your original posting are identical (modulo pid) on my system (puzzle).
Of course they are! the difference is not in compile time, but rather in *dynamic* link time - that is, in run time.
The interesting question here is this: how does the dynamic loader ld.so knows which version of a symbol to use during dynamic linkage given that more then one are available?
The answer is actually not trivial. A lecture I gave on the subject of dynamic linking on Haifux may help:
http://www.benyossef.com/presentations/dlink/
And for those who really want to get into it - a paper by Ulrich Drepper that knows so much more on the subject then I do:
http://people.redhat.com/drepper/dsohowto.pdf
:-)
Hope this helps, Gilad
================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
