Concurrent Programming on Windows
1008 pp., $49.99 ISBN: 978-0-321-43482-1
Let me get straight to the point -- anyone interested in parallel programming using the .NET Framework needs Joe Duffy's Concurrent Programming on Windows. It is the definitive work on the subject, written with great accuracy, clarity and an enthusiastic cadence that will prepare the reader for concurrent computing tasks. Duffy is one of the definitive experts on the topic, considering he was the progenitor of Parallel Language Integrated Query (PLINQ) which eventually morphed into the Parallel Extensions to the .NET Framework. While some of the book's source inspiration is from Joe's own weblog as well as some of his articles published in MSDN Magazine, a majority of the content was written and organized specifically to make learning concurrent programming on the Windows platform as painless and intuitive as possible. Duffy has indubitably succeeded with this herculean task.
Each of the 16 chapters are written more as essays rather than step-by-step tutorials. Taking this approach actually improved my retention of the material, as the author has a talent for describing such technical details in a digestible way. While there are occasional bold type keywords emphasized in these write-ups, there are no call-out boxes or tips written in six-point type along the margins. Some may bemoan the lack of such learning aids, but I found their absence kept me in the flow of the author's explanations and written voice. Plenty of code snippets help reinforce the ideas being asserted, but the book thankfully spends more ink on describing the processes and the reasons behind the technical approaches being advised versus having readers rely on reams of code listings to decipher the nuances of concurrency behind the code. In fact, this would be one of the few programming books that could actually make the cross media leap to an audio book format and survive with nearly all the key ideas and teachings intact.
Part I features two brief chapters setting the concurrent programming stage with the basic concepts of parallelism, state machines and coordinating data synchronization. Part II ("Mechanisms:) accounts for nearly half the book's weight and encompasses seven chapters covering threads and thread pools, kernel object, data and control synchronization, Asynchronous Programming Models (APMs), and the idea and utilization of fibers (a lightweight, cooperative scheduling thread-like mechanism that can reduce the cost of context switching; however, as of the .NET Framework 3.5 release, fibers remains exclusively accessible to Windows C++ developers). Part III contains five chapters centered around concurrent techniques such as memory consistency models, hardware atomicity, low-locks and deadlocks, priority inversion and starvation, general purpose lock-free FIFO queues, data and message-based parallelism and finally touching on the topic of performance and scalability as they apply to parallel hardware architectures, profiling in Visual Studio, garbage collection, and a discussion of Amdahl's Law ("the ability of a parallel algorithm to exhibit speedup over its sequential counterpart is inherently limited by the remaining sequential parts after parallelization") and Mellor-Crummey-Scott (MCS) Locks. The last section of the book on Systems covers overlapped, asynchronous and synchronous I/O thread cancellation, Single Threaded Apartment (STA) GUI threading models and .NET asynchronous GUI features, highlighting the BackgroundWorker package. The appendix contains two sections, one that lists 37 useful tips on designing reusable libraries for concurrent .NET programs (including obvious ones like "avoid blocking while you hold a lock" and not so obvious such as "consider using spin locks for high traffic leaf-level regions of code"), and the other providing an overview of the pieces that comprise the Parallel Extensions to .NET (based on the June 2008 Community Technology Preview) which includes the Task Parallel Library (TPL), Parallel Language Integrated Query (PLINQ) query provider and the various synchronous primitives and set of concurrent collections that are part of this package.
Whether you're a C++ or C# developer seeking the most comprehensive and enriching educational experience on the subject of parallel programming in the Windows environment, Concurrent Programming on Windows is a must have book. Much like Charles Petzold's highly regarded Programming Windows, Joe Duffy's book should have the honor of sitting on the same bookshelf as that essential tome, at least until the commercial computing world makes the full leap into parallel programming and such topics are as standard in future programming books as objects and threads are today.