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 d
Threads Primer: A Guide to Multithreaded Programming
โ Scribed by Bil Lewis, Daniel J. Berg
- Publisher
- Prentice Hall PTR
- Year
- 1995
- Tongue
- English
- Leaves
- 370
- Edition
- 1
- Category
- Library
No coin nor oath required. For personal study only.
โฆ Synopsis
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.
โฆ Table of Contents
PThreads Primer......Page 1
Dedication......Page 3
Table of Contents......Page 5
Acknowledgments to the Threads Primer......Page 23
Acknowledgments to the Pthreads Primer......Page 24
1. Introduction......Page 31
Background: Traditional Operating Systems......Page 35
What Is a Thread?......Page 38
Concurrency vs. Parallelism......Page 41
Scheduling......Page 43
Parallelism......Page 44
Throughput......Page 45
Communications......Page 46
Simplified Realtime Processing......Page 47
Distributed Objects......Page 48
Single Source for Multiple Platforms......Page 49
Inherently MT Programs......Page 50
Automatic Threading......Page 51
What About Shared Memory?......Page 52
Threads Standards......Page 53
Operating Systems......Page 54
SPECfp 95......Page 55
Summary......Page 56
Thread Libraries......Page 57
The Process Structure......Page 59
Lightweight Processes......Page 60
Threads and LWPs......Page 61
Solaris Multithreaded Model......Page 63
System Calls......Page 64
Signals......Page 66
Summary......Page 67
Thread Lifecycle......Page 69
Returning Status and Memory......Page 70
Suspending a Thread......Page 73
An Example: Create and Join......Page 74
Summary......Page 81
Different Models of Kernel Scheduling......Page 83
Thread Scheduling......Page 86
Process Contention Scope......Page 88
System Contention Scope......Page 92
Context Switching......Page 93
How Many LWPs?......Page 96
Realtime LWPs......Page 97
Binding LWPs to Processors......Page 100
Summary......Page 101
Atomic Actions and Atomic Instructions......Page 103
Critical Sections......Page 104
Synchronization Variables......Page 105
Mutexes......Page 106
Semaphores......Page 110
Condition Variables......Page 117
A Stoppable Producer/ Consumer Example......Page 124
Summary......Page 126
Readers/ Writer Locks......Page 127
Priority Inheritance Mutexes......Page 129
FIFO Mutexes......Page 130
Debug Mutexes......Page 132
Monitors......Page 133
Spin Locks......Page 135
Barriers......Page 137
Event Objects......Page 138
Multiple Wait Semaphores......Page 139
Win32 I/ O Completion Ports......Page 140
Cross- Process Synchronization Variables......Page 141
Initialization and Destruction......Page 142
Deadlocks......Page 144
Race Conditions......Page 145
Recovering from Deadlocks......Page 146
Summary......Page 147
Thread- Specific Data......Page 149
Global Variables, Constants, and Cheating......Page 155
Summary......Page 156
What Cancellation is......Page 157
Cancellation Cleanup Handlers......Page 159
Defined Cancellation Points......Page 160
A Cancellation Example......Page 161
Ensuring Bounded CPU Time......Page 167
Cancellation in pthread_ join()......Page 170
The Morning After......Page 171
Cancellation Safety......Page 172
Summary......Page 173
Signals in UNIX......Page 175
The Solaris Implementation of Signal Handling......Page 178
Don't Use Signal Handlers!......Page 180
Per- Thread Alarms......Page 181
Creating Threads for Events: SIGEV_ THREAD......Page 183
Summary......Page 184
Attribute Objects......Page 185
Thread Attribute Objects......Page 186
Synchronization Variable Initialization......Page 189
Condition Variable Attribute Objects......Page 190
POSIX Thread IDs......Page 191
Win32 Thread IDs and Thread Handles......Page 192
Initializing Your Data: pthread_ once()......Page 193
POSIX Namespace Restrictions......Page 194
Return Values and Error Reporting......Page 195
Constants Comments......Page 198
Pthread Futures......Page 199
Solaris Extensions......Page 200
Digital UNIX Extensions......Page 201
Comparing the OS/ 2, Win32, and POSIX Libraries......Page 202
Summary......Page 203
Multithreaded Kernels......Page 205
Are Libraries Safe?......Page 208
Stub Functions in libc......Page 215
Fork Safety and pthread_ atfork()......Page 216
Are Libraries Safe?......Page 217
Mixing Solaris Pthreads and UI Threads......Page 218
Comparisons of Different Implementations......Page 219
Summary......Page 220
Making Libraries Safe and Hot......Page 221
Making malloc() More Concurrent......Page 224
Manipulating Lists......Page 226
Single, Global Mutex......Page 228
Global RWLock with Global Mutex to Protect Salaries......Page 229
Global RWLock with Local Mutex to Protect Salaries......Page 231
One Local Lock......Page 233
Two Local Locks......Page 234
Local RWLock with Local Mutex to Protect Salaries......Page 235
Program Design......Page 236
Summary......Page 242
C++......Page 243
Java......Page 245
Pascal......Page 247
Eiffel......Page 248
RogueWave......Page 249
Dakota Scientific Software......Page 250
Centerline......Page 251
FSU Pthreads......Page 252
Pthread Debugger Project: SmartGDB......Page 253
Summary......Page 254
Static Lock Analyzer......Page 255
Using a Thread- Aware, Graphical Debugger......Page 256
Debug Mutexes......Page 259
Proctool......Page 261
TNFview......Page 262
Summary......Page 265
Optimization: Objectives and Objections......Page 267
CPU Time, I/ O Time, Contention, Etc......Page 269
Memory Latency......Page 270
I/ O Latency......Page 271
Throughput vs. Latency......Page 272
Limits on Speedup......Page 273
Amdahl's Law......Page 276
Performance Bottlenecks......Page 277
General Performance Optimizations......Page 279
Thread- Specific Performance Optimizations......Page 281
The Lessons of NFS......Page 284
Summary......Page 287
Shared- Memory, Symmetric Multiprocessors......Page 289
Bus Architectures......Page 292
LoadLocked/ StoreConditional and Compare and Swap......Page 299
Reducing Cache Misses......Page 301
Summary......Page 304
Threads and Windows......Page 305
Socket Server ( Master/ Slave Version)......Page 311
Socket Server ( Producer/ Consumer Version)......Page 317
Other Programs on the Web......Page 318
Summary......Page 319
A. Internet......Page 321
B. Books......Page 325
C. Timings......Page 329
D. Mistakes......Page 333
Function Descriptions......Page 337
Pthread Functions......Page 338
Pthread Attributes Objects......Page 340
POSIX Realtime Scheduling......Page 342
Mutexes......Page 345
Mutex Attributes Objects......Page 347
Condition Variables......Page 348
Condition Variable Attributes Objects......Page 350
Cancellation Functions......Page 352
Thread- Specific Data Functions......Page 353
Semaphores......Page 354
Signal Functions......Page 357
Stdio......Page 359
Glossary......Page 361
๐ SIMILAR VOLUMES
I would describe the books as concise, precise and extremely readable. The authors use fluid language and use the right technical terms in the right places. One of the best Computer Science books I have ever read. Definitely a good reference(though the book is not a comprehensive Operating Systems
Describes the design of the Solaris MT API, with references to distinctions in POSIX. Contains a set of example programs which illustrate the usage of the Solaris and POSIX APIs. Explains the use of programming tools: Thread Analyzer, LockLint, LoopTool, and Debugger.
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 d