30

I am trying to find the source code of pthread library. (I guess its a supposed to be a part of Linux source code)

But somehow can't find any good website that has it.

I like this website: http://lxr.linux.no/#linux+v2.6.34.1/ where I usually find what I need. Somehow pthread source is not searchable. Anyway, I wanted to mention that I need a link to a browsable (and searchable) website like that one.

Websites for browsing linux source can be a matter of personal taste. So all links to the pthread source are welcome.

Most probably I will end up bookmarking all of them, look thru them, and then accept the best answer.

durron597
  • 31,968
  • 17
  • 99
  • 158
bits
  • 8,110
  • 8
  • 46
  • 55

3 Answers3

34

pthreads are implemented on Linux in libc. The usual libc is glibc - the glibc pthreads implementation is called NPTL, and the source is available in gitweb.

caf
  • 233,326
  • 40
  • 323
  • 462
  • Does anyone use pth anymore? I guess so since I'm seeing a coreutils test failure possibly due to lack of pth at [FAIL: test-rwlock1 on 32-bit ARM](https://lists.gnu.org/archive/html/coreutils/2018-02/msg00011.html). – jww Feb 06 '18 at 19:16
6

You can find the source at both of these links:

http://www.opengroup.org/onlinepubs/009695399/basedefs/pthread.h.html

http://code.google.com/p/pthread-lib/source/browse/trunk/pthread-lib/src/ptl_array_list.c

tijko
  • 7,599
  • 11
  • 44
  • 64
eruciform
  • 7,680
  • 1
  • 35
  • 47
2

Did you look at GNU libc?

On my Debian box, I see

edd@mccoy:~$ dpkg -S /usr/lib/libpthread.so 
libc6-dev: /usr/lib/libpthread.so
edd@mccoy:~$ apt-cache show libc6-dev
Package: libc6-dev
Priority: optional
Section: libdevel
Installed-Size: 13172
Maintainer: GNU Libc Maintainers <debian-glibc@lists.debian.org>
Architecture: i386
Source: glibc
Version: 2.7-18lenny4
Replaces: man-db (<= 2.3.10-41), gettext (<= 0.10.26-1), ppp (<= 2.2.0f-24), 
          libgdbmg1-dev (<= 1.7.3-24)
Provides: libc-dev
Depends: libc6 (= 2.7-18lenny4), linux-libc-dev
Recommends: gcc | c-compiler
Suggests: glibc-doc, manpages-dev
Conflicts: libstdc++2.10-dev (<< 1:2.95.2-15), gcc-2.95 (<< 1:2.95.3-9), 
           binutils (<< 2.17cvs20070426-1), libc-dev
Filename: pool/updates/main/g/glibc/libc6-dev_2.7-18lenny4_i386.deb
Size: 3387248
MD5sum: 9cdb8401cead8afdd9f3e5da7bf673f8
SHA1: 01049f981a24dc0e5da8a3a1e57a8f2e91d7e57a
SHA256: 89c222ece39c417ee91f24d9f5619f58be330b111092379e4f09b93bcbfe834b
Description: GNU C Library: Development Libraries and Header Files
 Contains the symlinks, headers, and object files needed to compile
 and link programs which use the standard C library.
Build-Essential: yes
Tag: devel::lang:c, devel::library, implemented-in::c, role::devel-lib, suite::gnu

edd@mccoy:~$ 
Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • I tried to find it after reading your answer. But I can't figure out where to look. I am new to Linux source code stuff. I would appreciate if you could point me to a link. – bits Jul 11 '10 at 18:58
  • 1
    A Google search for "gnu libc source code" (no quotes) will lead you straight to the official site: http://www.gnu.org/software/libc/#Availability – David Z Jul 11 '10 at 19:02
  • 2
    Besides David's helpful answer, there is also source code for libc6 in whichever Linux distro you use -- for me it is as easy as `apt-get source libc6`. – Dirk Eddelbuettel Jul 11 '10 at 19:06
  • 1
    Thanks guys, First of all I didn't know that pthreads is a part of glibc. So... now I know. Secondly, following David's suggestion, I downloaded the linuxthreads tarball from http://ftp.gnu.org/gnu/glibc/ And that is helping me learn better. But I would love it more if I have a website where I can browse all this code. – bits Jul 11 '10 at 19:10
  • Dirk, Thanks for your suggestion as well. Unfortunately, I am living on windows to learn linux. But I will use that command to get libc6 source as soon as I am on linux env. For now, I am looking for an easy to browse website. – bits Jul 11 '10 at 19:12
  • 2
    Please note that linuxthreads is the old implementation of threads. The new one is called NPTL and should be in the normal glibc tarballs. – ninjalj Jul 11 '10 at 19:14