User-Level Native Thread Primitives (GThread) Library White Paper (G06.27+, H06.03+, J06.03+)

User-Level Native Thread Primitives (GThread Library) 02/15/2012
540065-004 Page 2 of 44
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
1.6. Changes to Support Protected User Stacks .................................................................................................. 5
1.7. Changes to Support 64-bit Addresses .......................................................................................................... 6
1.7.1. __LP64 Macro ..................................................................................................................................... 6
2. Thread Primitives ............................................................................................................................................... 7
2.1. Thread Context ............................................................................................................................................. 7
2.2. Declarations ................................................................................................................................................. 7
2.3. Thread Structures ......................................................................................................................................... 7
2.4. Alignment Considerations ............................................................................................................................ 9
2.5. Literals and Defines ..................................................................................................................................... 9
2.6. Setup and Initialization .............................................................................................................................. 13
2.7. Initiation ..................................................................................................................................................... 14
2.8. TNS/E Migration Aid ................................................................................................................................. 17
2.9. Access Functions ........................................................................................................................................ 17
2.10. Saving and Restoring Stacks ...................................................................................................................... 24
2.11. Measuring and Checking Stack Usage ....................................................................................................... 25
2.11.1. Thread Stack Usage ........................................................................................................................... 25
2.11.2. Stack ‘Guard Area’ Protection .......................................................................................................... 26
2.12. Context Manipulation................................................................................................................................. 28
2.13. Termination ................................................................................................................................................ 30
3. Usage .................................................................................................................................................................. 32
3.1. Native Static ............................................................................................................................................... 32
3.2. Swapped Master ......................................................................................................................................... 33
3.3. Architecture-Selected Models .................................................................................................................... 37
3.4. Mixed Models ............................................................................................................................................ 37
3.5. Checkpointing ............................................................................................................................................ 38
3.6. TNS/E Usage Changes ............................................................................................................................... 38
3.6.1. Thread Setup and Initialization ......................................................................................................... 38
3.6.2. Stack Allocation Control at Thread Initiation ................................................................................... 39
3.6.3. Thread Switching (Context Manipulation) ........................................................................................ 41
TABLE OF CONTENTS