Description

The original homepage for MIT Pthreads is http://www.mit.edu:8001/people/proven/pthreads.html

MIT Pthreads are IMHO a fairly stable and reliable implementation of the POSIX 1.c specification. Having found at least three versions of MIT pthreads, each at various patch levels, I am providing this page to facilitate the creation and maintenance of an "officially patched" version.

A nearly complete thread-safe version of libc is provided. Through creative use of thread-specific data, the traditional APIs for non-reentrant UNIX routines (like gethostbyname and strtok) has be preserved. Not all the routines have been reworked, although nearly all of the most commonly used are there.

Getting, Building, Installing and Using

Starting with the 1.8.8 release, PMPthreads comes distributed as both a gzipped tar and as RPMs. Below are descriptions of how to use both.

Gzipped Tar Release

  1. Use the download page to get it.
  2. You need gcc and make to build the binaries:
    • configure
    • make
    • make install
    These commands will install the distribution in the /usr/local/pthreads directory.
  3. Make the /usr/local/pthreads/bin/pgcc and /usr/local/pthreads/bin/pg++ scripts available to the path of your compile process.
    • Put /usr/local/pthreads/bin in your PATH or
    • Move the /usr/local/pthreads/bin/pgcc and /usr/local/pthreads/bin/pg++ script to a place already in your PATH or
    • Use /usr/local/pthreads/bin/pgcc as the CC variable in your application's Makefile
  4. When you compile your code, use the pgcc or pg++ script as your compiler. This will:
    • Point gcc to the pthread include files in /usr/local/pthreads/include
    • Point the linker to the pthread library in /usr/local/pthreads/lib
    • Link the libpthread.a library in the proper order
  5. That's all there is to it!

RPM Release for Linux

  1. Use the download page to get both the sources and binaries.
  2. As root user, execute the following:
    • rpm -ivh pmpthreads-1.8.8-1.i386.rpm
    • rpm -ivh pmpthreads-1.8.8-1.src.rpm
    These commands will install the sources in /usr/src/redhat/SOURCES directory and the binaries in the /usr/local/pthreads directory. Additionally, the pgcc and pg++ scripts will be installed in /usr/bin. The uninstall scripts invoked with the rpm -e pmpthreads command removes all the install code, including those in /usr/bin.
  3. (Optional) Uncompress and unarchive the sources to make them available for the debugger.
    • cd /usr/src/redhat/SOURCES
    • gunzip and untar the pmpthreads-1.8.8.tar.gz file
  4. When you compile your code, use the pgcc or pg++ script as your compiler. This will:
    • Point gcc to the pthread include files in /usr/local/pthreads/include
    • Point the linker to the pthread library in /usr/local/pthreads/lib
    • Link the libpthread.a library in the proper order
  5. That's all there is to it!

Limitations of MIT Pthreads

MIT Pthreads is a user-level library -- including everything good and bad about that fact. Take a look at the discussion Sean Walton and others put together about user/kernel-based threads for Linux in Linux Threads Frequently Asked Questions.

Although MIT Pthreads does not take advantage of SMP, on Linux it creates programs that are more easily debugged than those using kernel threads. It also provides support for wider array of POSIX 1.c applications thru its near total compliance to the standard.

Documents

Patched MIT POSIX Threads FAQ

Proven's Pthread Man Page

Code snippets and examples demonstrating the use of MIT Pthreads.

An in-depth description of PMPthread internal queue functions.

Variants and Extensions

Quark

MySQL

Current and Potential Projects

Full POSIX 1.c compliance


If you have comments or suggestions, email me at sdybiec@humanfactor.com