pthread - POSIX.1c Threading API of GNU Pth GNU Pth 1.0.0 (16-Jul-1999) Application Makefile # manually CFLAGS=-I/path/to/pth/include LDFLAGS=-L/path/to/pth/lib LIBS=-lpthread # automatically CFLAGS=`pthread-config --cflags` LDFLAGS=`pthread-config --ldflags` LIBS=`pthread-config --libs` All(!) application sources #include <pthread.h>

Overview
This is the IEEE Std. 1003.1c ("POSIX.1c") conforming threading API of GNU Portable Threads (Pth). This API is commonly known as ``POSIX threads'' or in short ``pthreads''. It is provided by Pth with the intention of backward compatibility to existing multithreaded applications. It is implemented by mapping the various pthread API functions to the corresponding Pth API functions.

Notes
A few notes which you should keep in mind when working with the Pth pthread API. First you've to always remember when working with this pthread library that it uses non-preeptive scheduling, because it's directly based on Pth (Pth for portability reasons is a pure non-preemptive thread scheduling system). So there is no implicit yielding of execution control and you cannot expect great concurrency in your application, of course. Nevertheless the responsiveness and concurrency of an event driven application is increased greatly. The underlaying Pth library is an explicit API which (mainly for portability reasons) does not perform any magic to prevent blocking system calls from blocking the whole process (instead of just the thread). In Pth one explicitly has to use non-blocking filedescriptors and pth_read() instead of read(), etc. So expect a blocking system call to block your whole process unless you use it in non-blocking mode or you have pthread.h included in all(!) your source files. This way you get some ``#define''s which map some important system functions to the Pth equivalents. There can be a conflict between the Pth pthread.h and a possibly existing vendor pthread.h header which was implicitly included by some standard vendor headers. When this occurs try to ``#define'' header-dependent values which prevent the inclusion of the vendor header.

Further Reading
First there is a small document included in the Pth source tree, pthread.ps from Sun Microsystems Inc, which is a very concise summary of the pthread API. Use this for a quick reference. Then there is ``The Single UNIX Specification, Version 2 - Threads'', from The Open Group of 1997 under http://www.opengroup.org/onlinepubs /007908799/xsh/threads.html. This is a very complete publically available description of the pthread API. Use this when you need details for free. Third, you can also buy the official standard from IEEE. It's IEEE POSIX 1003.1c-1995 standard (also known as ISO/IEC 9945-1:1996), which is available as part of the ANSI/IEEE 1003.1, 1996 edition, standard. Finally you can look at the files pthread.c and pthread.h in the Pth source tree for details of the implementation. pthread-config(1), pth(3). Ralf S. Engelschall rse@engelschall.com www.engelschall.com