多线程指南 电子版 英文 951KB PDF格式 少见难得的好东西 大家一块分享 求上载空间

realdreamer 2002-09-26 06:09:02
先附目录

Acknowledgments to the Threads Primer 23
Acknowledgments to the Pthreads Primer 24
1Introduction 31
2Concepts 35
Background: Traditional Operating Systems 35
What Is a Thread? 38
Kernel Interaction 41
Concurrency vsParallelism 41
System Calls43
Signals43
Synchronization43
Scheduling 43
The Value of Using Threads 44
Parallelism 44
Throughput 45
Responsiveness 46
Communications 46
System Resources 47
Simplified Realtime Processing 47
Simplified Signal Handling 48
Distributed Objects 48
Same Binary for Uniprocessors and Multiprocessors49
Program Structure49
Single Source for Multiple Platforms 49
What Kind of Programs to Thread?50
Inherently MT Programs 50
Not Obviously MT Programs 51
Automatic Threading 51
Programs Not to Thread52
What About Shared Memory? 52
Threads Standards 53
Performance 54
Operating Systems 54
NFS 55
SPECfp 9555
6 Threads Primer
SPECint_rate95.56
Summary .56
3Foundations .57
Implementation vsSpecification .57
Thread Libraries .57
The Process Structure.59
Lightweight Processes .60
Threads and LWPs.61
Solaris Multithreaded Model .63
System Calls .64
Signals .66
Summary .67
4Lifecycle .69
Thread Lifecycle .69
Returning Status and Memory .70
Exiting the Process .73
Suspending a Thread.73
Cancellation .74
An Example: Create and Join .74
Summary .81
5Scheduling .83
Different Models of Kernel Scheduling .83
Thread Scheduling .86
Process Contention Scope .88
System Contention Scope .92
Context Switching .93
Preemption .96
How Many LWPs? .96
Realtime LWPs .97
Allocation Domains .100
Binding LWPs to Processors .100
When Should You Care About Scheduling? .101
Summary .101
7
6Synchronization 103
Synchronization Issues 103
Atomic Actions and Atomic Instructions103
Critical Sections 104
Lock Your Shared Data! 105
Synchronization Variables 105
Mutexes 106
Semaphores 110
Condition Variables 117
A Stoppable Producer/Consumer Example124
Summary126
7Complexities 127
Complex Locking Primitives 127
Readers/Writer Locks127
Priority Inheritance Mutexes 129
FIFO Mutexes130
Recursive Mutexes 132
Non-Blocking Synchronization 132
Debug Mutexes 132
Monitors 133
Spin Locks 135
Other Synchronization Variables 137
Join 137
Barriers 137
Event Objects 138
OS/2 Critical Sections139
Win32 Critical Sections 139
Multiple Wait Semaphores 139
Message Queues140
Win32 I/O Completion Ports140
Cross-Process Synchronization Variables 141
Initialization and Destruction 142
Synchronization Problems 144
Deadlocks144
Race Conditions145
8 Threads Primer
Recovering from Deadlocks .146
Summary .147
8TSD .149
Thread-Specific Data .149
Thread Local Storage .155
Global Variables, Constants, and Cheating .155
Summary .156
9Cancellation .157
What Cancellation is .157
Cancellation Cleanup Handlers .159
Defined Cancellation Points .160
Unexpected Cancellation Points .161
A Cancellation Example .161
Using Cancellation .167
Ensuring Bounded CPU Time .167
Cancelling Sleeping Threads .170
Cancellation in pthread_join() .170
Cancellation in Condition Variables .171
The Morning After.171
Cancellation Safety .172
Mixing Cancellation Types .173
Changing State and Type in Libraries .173
Simple Polling .173
Summary .173
10Signals .175
Signals in UNIX .175
Async Safety .178
The Solaris Implementation of Signal Handling .178
Don’t Use Signal Handlers! .180
Per-Thread Alarms.181
Creating Threads for Events: SIGEV_THREAD.183
Summary .184
11Details .185
Attribute Objects.185
9
Thread Attribute Objects 186
Synchronization Variable Initialization 189
Mutex Attribute Objects 190
Condition Variable Attribute Objects 190
Semaphore Initialization 191
POSIX Thread IDs 191
Win32 Thread IDs and Thread Handles 192
Initializing Your Data: pthread_once() 193
POSIX Namespace Restrictions 194
Return Values and Error Reporting 195
Constants Comments 198
Pthread Futures 199
Pthread Extensions 200
Solaris Extensions 200
X/Open Extensions201
AIX Extensions 201
Digital UNIX Extensions 201
Comparing the OS/2, Win32, and POSIX Libraries 202
Summary203
12Libraries 205
The Threads Library 205
Multithreaded Kernels 205
Symmetric Multiprocessing 208
Are Libraries Safe?208
Stub Functions in libc 215
New Semantics for System Calls 216
Forking New Processes216
Fork Safety and pthread_atfork() 216
Executing a New Program 217
Are Libraries Safe?217
Threads Debugger Interface 218
Mixing Solaris Pthreads and UI Threads 218
Comparisons of Different Implementations 219
Summary220
10 Threads Primer
13Design .221
Making Libraries Safe and Hot .221
Making malloc() More Concurrent .224
Manipulating Lists .226
Single, Global Mutex .228
Global RWLock with Global Mutex to Protect Salaries.229
Global RWLock with Local Mutex to Protect Salaries.231
One Local Lock.233
Two Local Locks.234
Local RWLock with Local Mutex to Protect Salaries .235
Program Design .236
Summary .242
14Languages .243
C .243
C++.243
Java .245
Fortran .247
Ada.247
Pascal .247
SmallTalk .248
Lisp.248
Eiffel .248
Commercial Products.249
ObjectSpace.249
RogueWave .249
Geodesic Systems, LLC .250
Dakota Scientific Software .250
Adaptive Communication Environment.251
RT++ -- Higher Order Threads for C++ .251
Centerline .251
GNU (via Cygnus) .252
Pure Atria .252
Public Pthreads Implementations.252
FSU Pthreads .252
MIT Portable Pthreads.253
11
PCThreads 253
LinuxThreads253
Pthread Debugger Project: SmartGDB 253
Summary254
15Tools 255
Static Lock Analyzer 255
Using a Thread-Aware, Graphical Debugger 256
Debug Mutexes 259
Proctool 261
TNFview 262
Summary265
16Performance 267
Optimization: Objectives and Objections 267
CPU Time, I/O Time, Contention, Etc269
CPU270
Memory Latency 270
Memory Bandwidth 271
I/O Latency 271
Contention 272
Throughput vsLatency 272
Limits on Speedup273
Amdahl’s Law 276
Performance Bottlenecks 277
Benchmarks and Repeatable Testing 279
General Performance Optimizations 279
Thread-Specific Performance Optimizations 281
The Lessons of NFS 284
Summary287
17Hardware 289
Types of Multiprocessors 289
Shared-Memory, Symmetric Multiprocessors 289
Bus Architectures 292
LoadLocked/StoreConditional and Compare and Swap299
Memory Systems 301
Reducing Cache Misses.301
Summary .304
18Examples .305
Threads and Windows .305
Socket Server (Master/Slave Version) .311
Socket Server (Producer/Consumer Version) .317
Other Programs on the Web .318
Summary .319
AInternet .321
BBooks .325
CTimings .329
DMistakes .333
EAPIs .337
Function Descriptions .337
Pthread Functions.338
Pthread Attributes Objects .340
POSIX Realtime Scheduling .342
Mutexes .345
Mutex Attributes Objects.347
Condition Variables .348
Condition Variable Attributes Objects .350
Cancellation Functions.352
Thread-Specific Data Functions .353
Semaphores .354
Signal Functions .357
Stdio .359
Glossary 361

谁有上传空间, 请提供, 以让大家分享
...全文
73 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧