Asynchronous Agents

Rick Molloy, one of the masterminds behind the new concurrency runtime (concrt) and parallel patterns library (PPL), has written an article in the latest issue of MSDN Magazine demonstrating the new asynchronous agents library with the classic dining philosophers problem.

Concurrent Affairs: Solving The Dining Philosophers Problem With Asynchronous Agents

Enabling C++ developers to write highly concurrent applications is a major focus of Visual Studio 2010. The beta release includes the Concurrency Runtime, parallel libraries, and development tools aimed at addressing several common problems preventing developers from unlocking the performance potential inherent to multicore hardware. Notably, this includes ensuring that developers can identify and take advantage of opportunities for concurrency in their code, productively manage shared state and its side effects, and not having to worry about building low-overhead concurrency infrastructure that is scalable at run time on a variety of hardware.

In this article, I'm going to demonstrate how to use the new Asynchronous Agents Library included as part of Visual C++ 2010 to manage the difficulties that can arise with shared state. To show you how this works, I will walk through an implementation of a classic concurrency problem: Djikstra's Dining Philosophers. You'll see how the actor-based programming construct of an agent in combination with asynchronous message-passing APIs can be used to provide a correct and easy to understand solution to this problem that doesn't rely directly on threading or synchronization primitives.


No Comments