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:

    I don’t think of form as a kind of architecture. The architecture is the result of the forming. It is the kinesthetic and visual sense of position and wholeness that puts the thing into the realm of art.
    Roy Lichtenstein (b. 1923)

    It seems a fantastic paradox, but it is nevertheless a most important truth, that no architecture can be truly noble which is not imperfect.
    John Ruskin (1819–1900)

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