Reputation: 2564
I am using functions such as pthread_setaffinity_np from the /usr/include/nptl/pthread.h.
The linker is however complaining that the "pthread_setaffinity_np" is not found, as far as I understand, the linker is looking for the reference in the wrong pthread library (/usr/lib/libpthread.so) which doesn't include support for CPU affinity. I am on RedHat 4.
I believe I have to link to /lib/tls/libpthread-2.3.4.so which includes this function. However linking to libpthread-2.3.4.so caused other linker errors.
What is the proper way of linking to libpthread-2.3.4.so on RedHat 4?
Thanks in advance,
Paul
Upvotes: 0
Views: 1054
Reputation: 213375
as far as I understand, the linker is looking for the reference in the wrong pthread library
Your understanding is incorrect.
The /usr/lib/libpthread.so
is a linker script, which links your program with libpthread.so.0
and libpthread_nonshared.a
. The libpthread.so.0
is (should be) a symlink, most likely to libpthread-2.3.4.so
.
There are likely several versions of libpthread-2.3.4.so
installed on your system: one in /lib/i686
, one in /lib/tls
, perhaps also one in /lib
. Which one is used at runtime depends on your hardware and your kernel.
What do the following commands print?
find /lib -name 'libpthread.so.0' | xargs nm -A | grep pthread_setaffinity_np
ldd /usr/bin/date
Upvotes: 2
Reputation: 1
It probably might not work. NPTL is now in the GNU libc. And it is intimately related to the version of the kernel (and you are probably using some ancient distribution with an old kernel.).
The good solution is to upgrade your system to something providing a recent enough NPTL (and recent enough kernel) to suit your needs. Processor affinity is handled both inside the pthread library (often packaged with libc
) and inside the kernel (because it is related to the scheduler).
Why don't you install e.g. CentOS 6 (which is a derivative of RedHat)?
Upvotes: 0