Thread: I am confused by "Linux thread" and "NPTL"

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    284

    I am confused by "Linux thread" and "NPTL"

    What are the definitions and differences among:
    Linux thread,
    NPTL
    POSIX
    GLibC
    pthread
    ??
    I am totally confused by their relationships...

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    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) ) )

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    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.)
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981

  5. #5
    Registered User
    Join Date
    Apr 2007
    Posts
    284
    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.

  6. #6
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    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

  7. #7
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Codeplug View Post
    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.

Popular pages Recent additions subscribe to a feed