Udostępnij za pośrednictwem


Task Scheduler (Concurrency Runtime)

This section describes the important features of the Concurrency Runtime Task Scheduler. The Task Scheduler is useful when you want fine-tune the performance of your existing code that uses the Concurrency Runtime.

Tip

The Concurrency Runtime provides a default scheduler, and therefore you are not required to create one in your application. Because the Task Scheduler helps you fine-tune the performance of your applications, we recommend that you start with the Parallel Patterns Library (PPL) or the Asynchronous Agents Library if you are new to the Concurrency Runtime.

The Task Scheduler schedules and coordinates tasks at run time. A task is a unit of work that performs a specific job. A task can typically run in parallel with other tasks. The work that is performed by task group items, parallel algorithms, and asynchronous agents are all examples of tasks.

The Task Scheduler manages the details that are related to efficiently scheduling tasks on computers that have multiple computing resources. The Task Scheduler also uses the newest features of the underlying operating system. Therefore, applications that use the Concurrency Runtime automatically scale and improve on hardware that has expanded capabilities.

Comparing the Concurrency Runtime to Other Concurrency Models describes the differences between preemptive and cooperative scheduling mechanisms. The Task Scheduler uses cooperative scheduling and a work-stealing algorithm together with the preemptive scheduler of the operating system to achieve maximum usage of processing resources.

The Concurrency Runtime provides a default scheduler so that you do not have to manage infrastructure details. Therefore, you typically do not use the Task Scheduler directly. However, to meet the quality needs of your application, you can use the Task Scheduler to provide your own scheduling policy or associate schedulers with specific tasks. For example, suppose you have a parallel sorting routine that does not scale beyond four processors. You can use scheduler policies to create a scheduler that generates no more than four concurrent tasks. Running the sorting routine on this scheduler enables other active schedulers to use any remaining processing resources.

Title

Description

Scheduler Instances

Describes scheduler instances and how to use the Scheduler and CurrentScheduler classes to manage them. Use scheduler instances when you want to associate explicit scheduling policies with specific types of workloads.

Scheduler Policies

Describes the role of scheduler policies. Use scheduler policies when you want to control the strategy that the scheduler uses when it manages tasks.

Schedule Groups

Describes the role of schedule groups. Use schedule groups when you require a high degree of locality among tasks, for example, when a group of related tasks benefit from executing on the same processor node.

Lightweight Tasks

Describes the role of lightweight tasks. Lightweight tasks are useful when you adapt existing code to use the scheduling functionality of the Concurrency Runtime.

Contexts

Describes the role of contexts, the wait function, and the Context class. Use this functionality when you need control over when contexts block, unblock, and yield, or when you want to enable oversubscription in your application.

Memory Management Functions

Describes the Alloc and Free functions. These functions can improve memory performance by allocating and freeing memory in a concurrent manner.

Comparing the Concurrency Runtime to Other Concurrency Models

Describes the differences between preemptive and cooperative scheduling mechanisms.

Parallel Patterns Library (PPL)

Describes how to use various parallel patterns, for example, parallel algorithms, in your applications.

Asynchronous Agents Library

Describes how to use asynchronous agents in your applications.

Concurrency Runtime

Describes the Concurrency Runtime, which simplifies parallel programming, and contains links to related topics.