pthread - POSIX.1c Threading API of GNU Pth GNU Pth 1.2.3 (04-Feb-2000) Application Makefiles:
# manuallyCFLAGS=-I/path/to/pth/includeLDFLAGS=-L/path/to/pth/libLIBS=-lpthread
# automaticallyCFLAGS=`pthread-config --cflags`LDFLAGS=`pthread-config --ldflags`LIBS=`pthread-config --libs`
Application source files:
#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.
Supported Features The following defined feature macros in pthread.h indicate supported features:
#define _POSIX_THREADS#define _POSIX_THREAD_ATTR_STACKADDR#define _POSIX_THREAD_ATTR_STACKSIZE
The following undefined feature macros in pthread.h indicate (still) unsupported features:
#undef _POSIX_THREAD_PRIORITY_SCHEDULING#undef _POSIX_THREAD_PRIO_INHERIT#undef _POSIX_THREAD_PRIO_PROTECT#undef _POSIX_THREAD_PROCESS_SHARED#undef _POSIX_THREAD_SAFE_FUNCTIONS
Notes A few notes which you should keep in mind when working with the Pth Pthread API.
First you have to always remember when working with this Pthread library that it uses non-preemptive scheduling, because it is 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 unless you can pthread_* functions which could block and you cannot expect granular concurrency in your application, of course. Nevertheless the responsiveness and concurrency of an event driven application is increased greatly because of overlapping I/O.
There can be a conflict between the Pth pthread.h header and a possibly existing vendor /usr/include/pthread.h header which was implicitly included by some standard vendor headers (like /usr/include/unistd.h). 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[email protected]www.engelschall.com