NPTL binding for pthread pthread_condattr_setclock

I wrote some pthread code that uses timeouts for a condition variable, but to provide relative expectation, I set the clock type to CLOCK_MONOTONIC using pthread_condattr_setclock ().

To compile and link pthread_condattr_setclock () with RHEL4, I had to add -I / usr / include / nptl and -L / usr / lib / nptl to my gcc command line. I understand that the 2.6 kernel (which has RHEL4) uses the NPTL version of pthread by default, so why should I explicitly specify these paths to use this function?

This is just this function, which requires this from me: if I leave it, everything compiles and builds links without additional instructions (although the behavior of the code is then incorrect).

+3
source share
1 answer

From what I was able to find out, the pthread header and library in / usr / include and / usr / lib respectively are old LinuxThreads implementations, and I believe that they exist for backward compatibility (i.e. you have to build against the old interface) but at run time, the NPTL implementation is used (which has an interface that is a superset of the LinuxThreads interface).

Therefore, you can only use the new NPTL interface (i.e. if you need additional functionality), if you know that you need it, and, importantly, you know that the NPTL interface will be available at run time.

+1
source

Source: https://habr.com/ru/post/1734884/


All Articles