Foreword xix
Preface xxiii
Acknowledgments xxvii
About the Author xxix
Part I: Concepts 1
Chapter 1: Introduction 3
Why Concurrency? 3
Program Architecture and Concurrency 6
Layers of Parallelism 8
Why Not Concurrency? 10
Where Are We? 11
Chapter 2: Synchronization and Time 13
Managing Program State 14
Synchronization: Kinds and Techniques 38
Where Are We? 73
Part II: Mechanisms 77
Chapter 3: Threads 79
Threading from 10,001 Feet 80
The Life and Death of Threads 89
Where Are We? 124
Chapter 4: Advanced Threads 127
Thread State 127
Inside Thread Creation and Termination 152
Thread Scheduling 154
Where Are We? 180
Chapter 5: Windows Kernel Synchronization 183
The Basics: Signaling and Waiting 184
Using the Kernel Objects 211
Where Are We? 251
Chapter 6: Data and Control Synchronization 253
Mutual Exclusion 255
Reader/Writer Locks (RWLs) 287
Condition Variables 304
Where Are We? 312
Chapter 7: Thread Pools 315
Thread Pools 101 316
Windows Thread Pools 323
CLR Thread Pool 364
Performance When Using the Thread Pools 391
Where Are We? 398
Chapter 8: Asynchronous Programming Models 399
Asynchronous Programming Model (APM) 400
Event-Based Asynchronous Pattern 421
Where Are We? 427
Chapter 9: Fibers 429
An Overview of Fibers 430
Using Fibers 435
Additional Fiber-Related Topics 445
Building a User-Mode Scheduler 453
Where Are We? 473
Part III: Techniques 475
Chapter 10: Memory Models and Lock Freedom 477
Memory Load and Store Reordering 478
Hardware Atomicity 486
Memory Consistency Models 506
Examples of Low-Lock Code 520
Where Are We? 541
Chapter 11: Concurrency Hazards 545
Correctness Hazards 546
Liveness Hazards 572
Where Are We? 609
Chapter 12: Parallel Containers 613
Fine-Grained Locking 616
Lock Free 632
Coordination Containers 640
Where Are We? 654
Chapter 13: Data and Task Parallelism 657
Data Parallelism 659
Task Parallelism 684
Message-Based Parallelism 719
Cross-Cutting Concerns 720
Where Are We? 732
Chapter 14: Performance and Scalability 735
Parallel Hardware Architecture 736
Speedup: Parallel vs. Sequential Code 756
Spin Waiting 767
Where Are We? 781
Part IV: Systems 783
Chapter 15: Input and Output 785
Overlapped I/O 786
I/O Cancellation 822
Where Are We? 826
Chapter 16: Graphical User Interfaces 829
GUI Threading Models 830
.NET Asynchronous GUI Features 837
Where Are We? 860
Part V: Appendices 863
Appendix A: Designing Reusable Libraries for Concurrent .NET
Programs 865
The 20,000-Foot View 866
The Details 867
Appendix B: Parallel Extensions to .NET 887
Task Parallel Library 888
Parallel LINQ 910
Synchronization Primitives 915
Concurrent Collections 924
Index 931
Joe Duffy is the development lead, architect, and founder of the Parallel Extensions to the .NET Framework project at Microsoft. In addition to hacking code and managing a team of developers, he focuses on defining the long-term vision for the Parallel Extensions, in the hope of allowing mere mortals to safely exploit GPUs and SIMD-style processors.
“I have been fascinated with concurrency ever since I added
threading support to the Common Language Runtime a decade ago.
That’s also where I met Joe, who is a world expert on this topic.
These days, concurrency is a first-order concern for practically
all developers. Thank goodness for Joe’s book. It is a tour de
force and I shall rely on it for many years to come.”
—Chris Brumme, Distinguished Engineer, Microsoft
“I first met Joe when we were both working with the Microsoft CLR
team. At that time, we had several discussions about threading and
it was apparent that he was as passionate about this subject as I
was. Later, Joe transitioned to Microsoft’s Parallel Computing
Platform team where a lot of his good ideas about threading could
come to fruition. Most threading and concurrency books that I have
come across contain information that is incorrect and explains how
to solve contrived problems that good architecture would never get
you into in the first place. Joe’s book is one of the very few
books that I respect on the matter, and this respect comes from
knowing Joe’s knowledge, experience, and his ability to explain
concepts.”
—Jeffrey Richter, Wintellect
“There are few areas in computing that are as important, or
shrouded in mystery, as concurrency. It’s not simple, and Duffy
doesn’t claim to make it so—but armed with the right information
and excellent advice, creating correct and highly scalable systems
is at least possible. Every self-respecting Windows developer
should read this book.”
—Jonathan Skeet, Software Engineer, Clearswift
“What I love about this book is that it is both comprehensive in
its coverage of concurrency on the Windows platform, as well as
very practical in its presentation of techniques immediately
applicable to real-world software development. Joe’s book is a
‘must have’ resource for anyone building native or managed code
Windows applications that leverage concurrency!”
—Steve Teixeira, Product Unit Manager, Parallel Computing Platform,
Microsoft Corporation
“This book is a fabulous compendium of both theoretical knowledge
and practical guidance on writing effective concurrent
applications. Joe Duffy is not only a preeminent expert in the art
of developing parallel applications for Windows, he’s also a true
student of the art of writing. For this book, he has combined those
two skill sets to create what deserves and is destined to be a
long-standing classic in developers’ hands everywhere.”
—Stephen Toub, Program Manager Lead, Parallel Computing Platform,
Microsoft
“As chip designers run out of ways to make the individual chip
faster, they have moved towards adding parallel compute capacity
instead. Consumer PCs with multiple cores are now commonplace. We
are at an inflection point where improved performance will no
longer come from faster chips but rather from our ability as
software developers to exploit concurrency. Understanding the
concepts of concurrent programming and how to write concurrent code
has therefore become a crucial part of writing successful software.
With Concurrent Programming on Windows, Joe Duffy has done a great
job explaining concurrent concepts from the fundamentals through
advanced techniques. The detailed descriptions of algorithms and
their interaction with the underlying hardware turn a complicated
subject into something very approachable. This book is the perfect
companion to have at your side while writing concurrent software
for Windows.”
—Jason Zander, General Manager, Visual Studio, Microsoft
Ask a Question About this Product More... |