What is the difference between NPTL and POSIX threads?

后端 未结 3 802
暖寄归人
暖寄归人 2021-02-01 18:05

What is the basic difference between NPTL and POSIX threads? How have these two evolved?

3条回答
  •  失恋的感觉
    2021-02-01 18:30

    POSIX threads (pthread) is not an implementation, it is a API specification (a standard, on paper, in english) of several functions whose name starts with pthread_ and which are defined in header. POSIX is also a set of specifications.

    NPTL is now inside GNU Libc on Linux and is (or at least tries very hard to be) an implementation of POSIX threads. It is a bunch of source and binary code on your Linux system. An application compiled with gcc -pthread and linked with -pthread uses NPTL code on Linux today.

    addenda

    There exist alternative implementations of pthread-s: on Linux, the MUSL Libc aims to be Posix compliant (which means having pthreads); on other Posix systems (AIX, Solaris, ...) you also have pthreads (but they are not NPTL or Glibc).

提交回复
热议问题