Tru64 UNIX
Guide to the POSIX Threads Library


Begin Index

Contents (summary)
Preface Preface
Part 1 POSIX Threads Library Overview and Programming Guidelines
Chapter 1 Introducing Multithreaded Programming
Chapter 2 Objects and Operations
Chapter 3 Programming with Threads
Chapter 4 Writing Thread-Safe Libraries
Chapter 5 Using the Exceptions Package
Chapter 6 Examples
Part 2 POSIX.1 (pthread) Routines Reference
Part 3 HP Proprietary Interfaces: tis Routines Reference
Part 4 Appendixes
Appendix A Considerations for Tru64 UNIX Systems
Appendix B Considerations for OpenVMS Systems
Appendix C Debugging Multithreaded Applications
Appendix D Migrating from the d4 Interface
  Glossary
  Index
  Figures
  Examples
  Tables


Contents


Preface
Preface Preface
Part 1
Part 1 POSIX Threads Library Overview and Programming Guidelines
Chapter 1
1 Introducing Multithreaded Programming
     1.1     Advantages of Using Threads
     1.2     Overview of Threads
     1.3     Thread Execution
     1.4     Functional Models for Multithreaded Programming
         1.4.1         Boss/Worker Model
         1.4.2         Work Crew Model
         1.4.3         Pipelining Model
         1.4.4         Combination of Functional Models
     1.5     Programming Issues for Multithreaded Programs
     1.6     POSIX Threads Libraries and Interfaces
         1.6.1         The pthread Multithreading Interface
             1.6.1.1             Optionally Implemented POSIX.1 Routines
         1.6.2         Thread-Independent Services Interface
         1.6.3         Undocumented and Obsolete Interfaces
             1.6.3.1             The cma Interface
             1.6.3.2             The d4 (DCEthread) Interfaces
Chapter 2
2 Objects and Operations
     2.1     Threads and Synchronization Objects
     2.2     Attributes Objects
     2.3     Thread Operations
         2.3.1         Creating a Thread
         2.3.2         Setting the Attributes of a New Thread
             2.3.2.1             Setting the Inherit Scheduling Attribute
             2.3.2.2             Setting the Scheduling Policy Attribute
                 2.3.2.2.1                 Techniques for Setting the Scheduling Policy Attribute
                 2.3.2.2.2                 Comparing Throughput and Real-Time Policies
                 2.3.2.2.3                 Portability of Scheduling Policy Settings
             2.3.2.3             Setting the Scheduling Parameters Attribute
             2.3.2.4             Setting the Stacksize Attribute
             2.3.2.5             Setting the Stack Address Attribute
             2.3.2.6             Setting the Guardsize Attribute
             2.3.2.7             Setting the Contention Scope Attribute
         2.3.3         Terminating a Thread
             2.3.3.1             Cleanup Handlers
         2.3.4         Detaching and Destroying a Thread
         2.3.5         Joining With a Thread
         2.3.6         Scheduling a Thread
             2.3.6.1             Calculating the Scheduling Priority
             2.3.6.2             Effects of Scheduling Policy
         2.3.7         Canceling a Thread
             2.3.7.1             Thread Cancelation Implemented Using Exceptions
             2.3.7.2             Thread Return Value After Cancelation
             2.3.7.3             Controlling Thread Cancelation
             2.3.7.4             Deferred Cancelation Points
             2.3.7.5             Cleanup from Deferred Cancelation
             2.3.7.6             Cleanup from Asynchronous Cancelation
             2.3.7.7             Example of Thread Cancelation Code
     2.4     Synchronization Objects
         2.4.1         Mutexes
             2.4.1.1             Normal Mutex
             2.4.1.2             Default Mutex
             2.4.1.3             Recursive Mutex
             2.4.1.4             Errorcheck Mutex
             2.4.1.5             Mutex Operations
             2.4.1.6             Mutex Attributes
         2.4.2         Condition Variables
         2.4.3         Condition Variable Attributes
         2.4.4         Read-Write Locks
             2.4.4.1             Thread Priority and Writer Precedence for Read-Write Locks
             2.4.4.2             Initializing and Destroying a Read-Write Lock
             2.4.4.3             Read-Write Lock Attributes
     2.5     Process-Shared Synchronization Objects
         2.5.1         Programming Considerations
         2.5.2         Process-Shared Mutexes
         2.5.3         Process-Shared Condition Variables
         2.5.4         Process-Shared Read-Write Locks
     2.6     Thread-Specific Data
Chapter 3
3 Programming with Threads
     3.1     Designing Code for Asynchronous Execution
         3.1.1         Avoid Passing Stack Local Data
         3.1.2         Initialize Objects Before Thread Creation
         3.1.3         Do Not Use Scheduling As Synchronization
     3.2     Memory Synchronization Between Threads
     3.3     Sharing Memory Between Threads
         3.3.1         Using Static Memory
         3.3.2         Using Stack Memory
         3.3.3         Using Dynamic Memory
     3.4     Managing a Thread's Stack
         3.4.1         Sizing the Stack
         3.4.2         Using Stack Overflow Warning and Stack Guard Areas
         3.4.3         Diagnosing Stack Overflow Errors
     3.5     Scheduling Issues
         3.5.1         Real-Time Scheduling
         3.5.2         Priority Inversion
         3.5.3         Dependencies Among Scheduling Attributes and Contention Scope
     3.6     Using Synchronization Objects
         3.6.1         Distinguishing Proper Usage of Mutexes and Condition Variables
         3.6.2         Avoiding Race Conditions
         3.6.3         Avoiding Deadlocks
         3.6.4         Signaling a Condition Variable
         3.6.5         Static Initialization Inappropriate for Stack-Based Synchronization Objects
     3.7     Granularity Considerations
         3.7.1         Determinants of a Program's Granularity
             3.7.1.1             Alpha Processor Granularity
             3.7.1.2             VAX Processor Granularity
         3.7.2         Compiler Support for Determining the Program's Actual Granularity
         3.7.3         Word Tearing
         3.7.4         Alignments of Members of Composite Data Objects
         3.7.5         Avoiding Granularity-Related Errors
             3.7.5.1             Changing the Composite Data Object's Layout
             3.7.5.2             Maintaining the Composite Data Object's Layout
             3.7.5.3             Using One Mutex Per Composite Data Object
         3.7.6         Identifying Possible Word-Tearing Situations Using Visual Threads
     3.8     One-Time Initialization
     3.9     Managing Dependencies Upon Other Libraries
         3.9.1         Thread Reentrancy
         3.9.2         Thread Safety
         3.9.3         Lacking Thread Safety
             3.9.3.1             Using Mutex Around Call to Unsafe Code
             3.9.3.2             Using the Global Lock
             3.9.3.3             Using or Copying Static Data Before Releasing the Mutex
         3.9.4         Use of Multiple Threads Libraries Not Supported
     3.10     Detecting Error Conditions
         3.10.1         Bugcheck Information
         3.10.2         Interpreting a Bugcheck


Previous Next Contents Index