Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio
Visual C++
Concurrency Runtime
Collapse All/Expand All Collapse All
Visual Studio 2010 - Visual C++
Concurrency Runtime

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

The Concurrency Runtime is a concurrent programming framework for C++. The Concurrency Runtime simplifies parallel programming and helps you write robust, scalable, and responsive parallel applications. The Concurrency Runtime raises the level of abstraction so that you do not have to manage the infrastructure details that are related to concurrency. The Concurrency Runtime also enables you to specify scheduling policies that meet the quality of service demands of your applications.

A concurrency runtime provides uniformity and predictability to applications and application components that run simultaneously. Two examples of the benefits of a concurrency runtime are cooperative task scheduling and cooperative blocking.

The Concurrency Runtime uses a cooperative task scheduler that implements a work-stealing algorithm to efficiently distribute work among computing resources. For example, consider an application that has two threads that are both managed by the same runtime. If one thread finishes its scheduled task, it can offload work from the other thread. This mechanism balances the overall workload of the application.

The Concurrency Runtime also provides synchronization primitives that use cooperative blocking to synchronize access to resources. For example, consider a task that must have exclusive access to a shared resource. By blocking cooperatively, the runtime can use the remaining quantum to perform another task as the first task waits for the resource. This mechanism promotes maximum usage of computing resources.

The Concurrency Runtime is divided into four components: the Parallel Patterns Library (PPL), the Asynchronous Agents Library, the Task Scheduler, and the Resource Manager. These components reside between the operating system and applications. The following illustration shows how the Concurrency Runtime components interact among the operating system and applications:

Concurrency Runtime Architecture

The Concurrency Runtime Architecture

The Concurrency Runtime is highly composable, that is, you can combine existing functionality to do more. The Concurrency Runtime composes many features, such as parallel algorithms, from lower-level components.

The following sections provide a brief overview of what each component provides and when to use it.

Parallel Patterns Library

The Parallel Patterns Library (PPL) provides general-purpose containers and algorithms for performing fine-grained parallelism. The PPL enables imperative data parallelism by providing parallel algorithms that distribute computations on collections or on sets of data across computing resources. It also enables task parallelism by providing task objects that distribute multiple independent operations across computing resources.

Use the Parallel Patterns Library when you have a local computation that can benefit from parallel execution. For example, you can use the parallel_for algorithm to transform an existing for loop to act in parallel.

For more information about the Parallel Patterns Library, see Parallel Patterns Library (PPL).

Asynchronous Agents Library

The Asynchronous Agents Library (or just Agents Library) provides both an actor-based programming model and message passing interfaces for coarse-grained dataflow and pipelining tasks. Asynchronous agents enable you to make productive use of latency by performing work as other components wait for data.

Use the Agents Library when you have multiple entities that communicate with each other asynchronously. For example, you can create an agent that reads data from a file or network connection and then uses the message passing interfaces to send that data to another agent.

For more information about the Agents Library, see Asynchronous Agents Library.

Task Scheduler

The Task Scheduler schedules and coordinates tasks at run time. The Task Scheduler is cooperative and uses a work-stealing algorithm to achieve maximum usage of processing resources.

The Concurrency Runtime provides a default scheduler so that you do not have to manage infrastructure details. However, to meet the quality needs of your application, you can also provide your own scheduling policy or associate specific schedulers with specific tasks. 

For more information about the Task Scheduler, see Task Scheduler (Concurrency Runtime).

Resource Manager

The role of the Resource Manager is to manage computing resources, such as processors and memory. The Resource Manager responds to workloads as they change at run time by assigning resources to where they can be most effective.

The Resource Manager serves as an abstraction over computing resources and primarily interacts with the Task Scheduler. However, you can use the Resource Manager to integrate the computing resource management of the Concurrency Runtime with your own concurrency library. You can also use the Resource Manager to fine-tune the performance of the Concurrency Runtime with your applications.  

The following table shows the header files that are associated with each component of the Concurrency Runtime:

Component

Header Files

Parallel Patterns Library (PPL)

ppl.h

concurrent_queue.h

concurrent_vector.h

Asynchronous Agents Library

agents.h

Task Scheduler

concrt.h

Resource Manager

concrtrm.h

The Concurrency Runtime is declared in the Concurrency namespace. The Concurrency::details namespace supports the Concurrency Runtime framework, and is not intended to be used directly from your code.

The Concurrency Runtime is provided as part of the C Runtime Library (CRT). For more information about how to build an application that uses the CRT, see C Run-Time Libraries.

Conventions (Concurrency Runtime)

Describes the common coding conventions that make the Concurrency Runtime easier to use.

Parallel Patterns Library (PPL)

Describes how to use various parallel patterns, such as parallel algorithms, in your applications.

Asynchronous Agents Library

Describes how to use asynchronous agents in your applications.

Synchronization Data Structures

Describes the various synchronization primitives that the Concurrency Runtime provides.

Task Scheduler (Concurrency Runtime)

Describes how to use the Task Scheduler to adjust the performance of your applications.

Exception Handling in the Concurrency Runtime

Describes the role of exception handling in the Concurrency Runtime.

Further Reading (Concurrency Runtime)

Provides links to additional sources of information about Concurrency Runtime.

Reference (Concurrency Runtime)

Provides reference material for the Concurrency Runtime library.

Parallel Programming in the .NET Framework

Describes the parallel programming functionality that is provided by the .NET Framework version 4 Beta 2.

© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker