PDA

View Full Version : I am confused by "Linux thread" and "NPTL"



meili100
03-26-2008, 04:08 PM
What are the definitions and differences among:
Linux thread,
NPTL
POSIX
GLibC
pthread
??
I am totally confused by their relationships...

brewbuck
03-26-2008, 04:21 PM
If I could, I'd draw a Venn diagram. The most general of these terms is glibc, which is a C library which implements POSIX as well as other things. POSIX is an overarching standard for UNIX-like user APIs. Pthreads is a part of POSIX. NPTL is an implementation of Pthreads. Linux Threads is a different implementation of Pthreads.

So, the concepts are nested this way:

glibc (posix (pthreads (ntpl, linuxthreads) ) )

dwks
03-26-2008, 05:13 PM
Note that POSIX and pthreads are standards (well, especially POSIX). The other things mentioned are specific libraries or (in the case of NPTL and Linux Threads) implementations of standards.

It's like the difference between a "laptop" and a "Toshiba". A laptop is a general thing, while a Toshiba is a specific instance of a laptop. (Or can be.)

Codeplug
03-26-2008, 06:22 PM
An interested read:
Linux threading models compared: LinuxThreads and NPTL (http://www-128.ibm.com/developerworks/linux/library/l-threading.html)gg

meili100
03-27-2008, 11:58 AM
Thanks all. That is to say, the code to use thread can be the same even if you migrate your system from linuxthread to NPTL. Say, you can use pthread_create(...) to create a thread and the code (even binary) doesn't need to be changed, because glibc is dynamically linked.

Codeplug
03-27-2008, 12:01 PM
That may be true for glibc functions - but I don't think pthread_create() is in there. If you are migrating from LinuxThreads to NPTL, then a re-build will be needed.

gg

brewbuck
03-27-2008, 12:14 PM
That may be true for glibc functions - but I don't think pthread_create() is in there. If you are migrating from LinuxThreads to NPTL, then a re-build will be needed.

gg

Are you sure? pthreads on Linux comes from libpthread.so, so it might just be drop-in replaceable, assuming NPTL also lives in a library called "libpthread.so," or you could at least symlink it to make it appear so.

I don't guarantee it would work, but if I were designing a new pthreads library, I'd try to make it possible to do this.