Providing an overview of the Solaris and POSIX multithreading architectures, this book explains threads at a level that is completely accessible to programmers and system architects with no previous knowledge of threads. Covers the business and technical benefits of threaded programs, along with discussions of third party software that is threaded, pointing out the benefits. For programmers, system architects, and technical programmer managers. Providing an overview of the Solaris and POSIX multithreading architectures, this book explains threads at a level that is completely accessible to programmers and system architects with no previous knowledge of threads. It covers the business and technical benefits of threaded programs, along with discussions of third party software that is threaded. Contents......Page 3 Preface......Page 25 How This Book Is Organized......Page 26 Introduction 1......Page 29 Background: Traditional Operating Systems......Page 33 What Is a Thread?......Page 36 Concurrency vs. Parallelism......Page 39 Scheduling......Page 41 Parallelism......Page 42 Throughput......Page 43 Communications......Page 44 Simplified Realtime Processing......Page 45 Distributed Objects......Page 46 Single Source for Multiple Platforms......Page 47 Inherently MT Programs......Page 48 Automatic Threading......Page 49 What About Shared Memory?......Page 50 Threads Standards......Page 51 Operating Systems......Page 52 SPECfp 95......Page 53 Summary......Page 54 Thread Libraries......Page 55 The Process Structure......Page 57 Lightweight Processes......Page 58 Threads and LWPs......Page 59 Solaris Multithreaded Model......Page 61 System Calls......Page 62 Signals......Page 64 Summary......Page 65 Thread Lifecycle......Page 67 Returning Status and Memory......Page 68 Suspending a Thread......Page 71 An Example: Create and Join......Page 72 Summary......Page 79 Many Threads on One LWP......Page 81 One Thread per LWP......Page 82 The Two- Level Model......Page 83 Thread Scheduling......Page 84 Process Contention Scope......Page 86 System Contention Scope......Page 90 Context Switching......Page 91 How Many LWPs?......Page 94 Realtime LWPs......Page 95 Binding LWPs to Processors......Page 98 Summary......Page 99 Atomic Actions and Atomic Instructions......Page 101 Critical Sections......Page 102 Synchronization Variables......Page 103 Mutexes......Page 104 Semaphores......Page 108 Condition Variables......Page 115 A Stoppable Producer/ Consumer Example......Page 122 Summary......Page 124 Readers/ Writer Locks......Page 125 Priority Inheritance Mutexes......Page 127 FIFO Mutexes......Page 128 Debug Mutexes......Page 130 Monitors......Page 131 Spin Locks......Page 133 Barriers......Page 135 Event Objects......Page 136 Interlocked Instructions......Page 137 Win32 I/ O Completion Ports......Page 138 Cross- Process Synchronization Variables......Page 139 Initialization and Destruction......Page 140 Deadlocks......Page 142 Race Conditions......Page 143 Recovering from Deadlocks......Page 144 Summary......Page 145 Thread- Specific Data......Page 147 Global Variables, Constants, and Cheating......Page 153 Summary......Page 154 What Cancellation is......Page 155 Cancellation Cleanup Handlers......Page 157 Defined Cancellation Points......Page 158 A Cancellation Example......Page 159 Ensuring Bounded CPU Time......Page 165 Cancellation in......Page 168 The Morning After......Page 169 Cancellation Safety......Page 170 Summary......Page 171 Signals in UNIX......Page 173 The Solaris Implementation of Signal Handling......Page 176 Don’t Use Signal Handlers!......Page 178 Per- Thread Alarms......Page 179 Creating Threads for Events:......Page 181 Summary......Page 182 Attribute Objects......Page 183 Thread Attribute Objects......Page 184 Synchronization Variable Initialization......Page 187 Condition Variable Attribute Objects......Page 188 POSIX Thread IDs......Page 189 Win32 Thread IDs and Thread Handles......Page 190 Initializing Your Data:......Page 191 POSIX Namespace Restrictions......Page 192 Return Values and Error Reporting......Page 193 Constants Comments......Page 196 Pthread Futures......Page 197 Solaris Extensions......Page 198 Digital UNIX Extensions......Page 199 Comparing the OS/ 2, Win32, and POSIX Libraries......Page 200 Summary......Page 201 Multithreaded Kernels......Page 203 Are Libraries Safe?......Page 206 Stub Functions in libc......Page 213 Fork Safety and......Page 214 Are Libraries Safe?......Page 215 Mixing Solaris Pthreads and UI Threads......Page 216 Comparisons of Different Implementations......Page 217 Summary......Page 218 Making Libraries Safe and Hot......Page 219 Making More Concurrent......Page 222 Manipulating Lists......Page 224 Single, Global Mutex......Page 226 Global RWLock with Global Mutex to Protect Salaries......Page 227 Global RWLock with Local Mutex to Protect Salaries......Page 229 One Local Lock......Page 231 Two Local Locks......Page 232 Local RWLock with Local Mutex to Protect Salaries......Page 233 Program Design......Page 234 Summary......Page 240 C++......Page 241 Java......Page 243 Pascal......Page 245 Eiffel......Page 246 RogueWave......Page 247 Dakota Scientific Software......Page 248 Centerline......Page 249 FSU Pthreads......Page 250 Pthread Debugger Project: SmartGDB......Page 251 Summary......Page 252 Static Lock Analyzer......Page 253 Using a Thread- Aware, Graphical Debugger......Page 254 Debug Mutexes......Page 257 Proctool......Page 259 TNFview......Page 260 Summary......Page 263 Optimization: Objectives and Objections......Page 265 CPU Time, I/ O Time, Contention, Etc.......Page 267 Memory Latency......Page 268 I/ O Latency......Page 269 Throughput vs. Latency......Page 270 Limits on Speedup......Page 271 Amdahl’s Law......Page 274 Performance Bottlenecks......Page 275 General Performance Optimizations......Page 277 Thread- Specific Performance Optimizations......Page 279 The Lessons of NFS......Page 282 Summary......Page 285 Shared- Memory, Symmetric Multiprocessors......Page 287 Bus Architectures......Page 290 LoadLocked/ StoreConditional and Compare and Swap......Page 297 Reducing Cache Misses......Page 299 Summary......Page 302 Threads and Windows......Page 303 Socket Server (Master/ Slave Version)......Page 309 Socket Server (Producer/ Consumer Version)......Page 315 Other Programs on the Web......Page 316 Summary......Page 317 Vendor’s Threads Pages......Page 319 Other Pointers......Page 320 The Authors on the Net......Page 321 Threads Books......Page 323 BookmarkTitle:......Page 0 Related Books......Page 325 Timings C......Page 327 Mistakes D......Page 331 Function Descriptions......Page 335 Pthread Functions......Page 336 Pthread Attributes Objects......Page 338 POSIX Realtime Scheduling......Page 340 Mutexes......Page 343 Mutex Attributes Objects......Page 345 Condition Variables......Page 346 Condition Variable Attributes Objects......Page 348 Cancellation Functions......Page 350 Thread- Specific Data Functions......Page 351 Semaphores......Page 352 Signal Functions......Page 355 Stdio......Page 357 Glossary......Page 359 Provides an overview of the Solaris and POSIX multithreading architectures. This book explains threads to programmers and system architects with no previous knowledge of threads. It covers the business and technical benefits of threaded programs, along with discussions of third party software that is threaded, pointing out the benefits.