4.6 Introduction to the Pthread Library
The Pthread library supplies the API to create and manage the threads in your application. The Pthread library is based on a standardized programming interface for the creation and maintenance of threads. The thread interface has been specified by the IEEE standards committee in the POSIX 1003.1c standard. Third-party vendors supply an implementation that adheres to the POSIX standard. Their implementation is referred to as Pthreads or POSIX thread library.
The Pthread library contains over 60 functions that can be classified into the following categories:
-
Thread Management Functions
-
Thread configuration
-
Thread cancellation
-
Thread scheduling
-
Thread specific data
-
Signals
-
Thread attribute functions
-
Thread attribute configuration
-
Thread attribute stack configuration
-
Thread attribute scheduling configuration
-
-
-
Mutex Functions
-
Mutex configuration
-
Priority management
-
Mutex attribute functions
-
Mutex attribute configuration
-
Mutex attribute protocol
-
Mutex attribute priority management
-
-
-
Condition Variable Functions
-
Condition variable configuration
-
Condition variable attribute functions
-
Condition variable attribute configuration
-
Condition variable sharing functions
-
-
The Pthread library can be implemented in any language but in order to be compliant with the POSIX standard, they must comply to the standardized interface and behave in the manner specified. The Pthread library is not the only thread API implementation. Hardware and third-party vendors have implemented their own proprietary thread APIs. For example, the Sun environment supports the Pthread library and their own Solaris thread library. In this chapter, we discuss some Pthread functions that implement thread management.