Parallel Extensions - Architecture

Architecture

The main concept in the Parallel Extensions to .NET is a Task, which is a small unit of code, usually represented as a lambda function, that can be executed independently. Both PLINQ and the TPL API provides methods to create the Tasks - PLINQ divides a query into smaller Tasks, and the Parallel.For, Parallel.ForEach and Parallel.Invoke methods divide a loop into Tasks.

PFX includes a Task Manager object which schedules the Tasks for execution. A Task Manager contains a global queue of Tasks, which are then executed. In addition, it also encapsulates multiple threads onto which the Tasks are executed. By default, as many threads as there are processors (or processor cores) on the system are created, though this number may be manually modified. Each thread is associated with a thread-specific queue of Tasks. When idle, each thread picks up a batch of Tasks and puts them on its local queue, where they are then executed, one by one. If the global queue is empty, a thread will look for Tasks in the queues of its peers, and will take the Tasks which have been in the queue the longest (task stealing). When in execution, the Tasks will be executed independently, with the change in state of one Task independent of others. As a result, if they use a shared resource, they still need to be synchronized manually using locks or other constructs.

Read more about this topic:  Parallel Extensions

Famous quotes containing the word architecture:

    The principle of the Gothic architecture is infinity made imaginable.
    Samuel Taylor Coleridge (1772–1834)

    Polarized light showed the secret architecture of bodies; and when the second-sight of the mind is opened, now one color or form or gesture, and now another, has a pungency, as if a more interior ray had been emitted, disclosing its deep holdings in the frame of things.
    Ralph Waldo Emerson (1803–1882)

    Defaced ruins of architecture and statuary, like the wrinkles of decrepitude of a once beautiful woman, only make one regret that one did not see them when they were enchanting.
    Horace Walpole (1717–1797)