User-Level Native Thread Primitives (GThread) Library White Paper (G06.26+)

User-Level Native Thread Primitives (GThread Library) 03/31/2005
Hewlett-Packard Company--540065-001 Page 2 of 46
1.
INTRODUCTION...............................................................................................................................................3
1.1. OVERVIEW ....................................................................................................................................................3
1.2. BACKGROUND AND DEFINITIONS ..................................................................................................................3
1.3. THREAD MODEL VARIATIONS.......................................................................................................................4
1.4. USER THREAD SUPPORT ...............................................................................................................................5
1.5. CHANGES FOR TNS/E ...................................................................................................................................5
2. THREAD PRIMITIVES ....................................................................................................................................7
2.1. THREAD CONTEXT........................................................................................................................................7
2.2. DECLARATIONS.............................................................................................................................................7
2.3. THREAD STRUCTURES...................................................................................................................................8
2.4. ALIGNMENT CONSIDERATIONS......................................................................................................................9
2.5. LITERALS AND DEFINES ..............................................................................................................................10
2.6. SETUP AND INITIALIZATION.........................................................................................................................14
2.7. INITIATION ..................................................................................................................................................15
2.8. TNS/E MIGRATION AID ..............................................................................................................................17
2.9. ACCESS FUNCTIONS....................................................................................................................................18
2.10. SAVING AND RESTORING STACKS ...............................................................................................................26
2.11. MEASURING AND CHECKING STACK USAGE................................................................................................27
2.11.1. Thread Stack Usage...........................................................................................................................27
2.11.2. Stack ‘Guard Area’ Protection..........................................................................................................28
2.12. CONTEXT MANIPULATION...........................................................................................................................30
2.13. TERMINATION .............................................................................................................................................33
3. USAGE...............................................................................................................................................................34
3.1. NATIVE STATIC ...........................................................................................................................................34
3.2. SWAPPED MASTER ......................................................................................................................................35
3.3. ARCHITECTURE-SELECTED MODELS...........................................................................................................39
3.4. MIXED MODELS ..........................................................................................................................................40
3.5. CHECKPOINTING..........................................................................................................................................40
3.6. TNS/E USAGE CHANGES ............................................................................................................................41
3.6.1. Thread Setup and Initialization.........................................................................................................41
3.6.2. Stack Allocation Control at Thread Initiation...................................................................................41
3.6.3. Thread Switching (Context Manipulation)........................................................................................43
Table of Contents