Parallel FX Library
From Wikipedia, the free encyclopedia
| This article or section contains information about scheduled or expected future software. The content may change as the software release approaches and more information becomes available. |
Parallel FX Library (PFX) is a managed concurrency library being developed by a collaboration between Microsoft Research and the CLR team at Microsoft for inclusion with a future revision of the .NET Framework. It is composed of two parts: Parallel LINQ (PLINQ) and Task Parallel Library (TPL).[1][2] It also consists of a set of Coordination Data Structures (CDS) - a set of data structures used to synchronize and co-ordinate the execution of concurrent tasks.[3] The library was released as a CTP on November 29, 2007[4] and refreshed again in December 2007 and June 2008.[3]
Contents |
[edit] PLINQ
- See also: Language Integrated Query
PLINQ is a concurrent query execution engine for LINQ, parallelizing the execution of queries on objects (LINQ to Objects) and XML data (LINQ to XML). PLINQ is intended for exposing data parallelism by use of queries.[1] Any computation on objects, that has been implemented as queries can be parallelized by PLINQ. However, the objects need to implement the IParallelEnumerable interface, which is defined by PLINQ itself. Internally it used TPL for execution.[3][5]
[edit] TPL
Task Parallel Library (TPL) is the task parallelism component of PFX.[1] It exposes parallel constructs like a parallel for or while loop, using regular method calls and delegates. As such, the constructs can be used from any language supporting the .NET Framework. The job of spawning and terminating threads, as well as scaling the number of threads according to the number of available processors is done by the library itself.[2]
TPL also includes other constructs such as Task and Future. A Task is an action that can be executed independent of the rest of the program. In that sense, it is equivalent to a thread, except that the programmer is relieved of the job of synchronizing the execution of the thread. A Future is a specialized task that returns a result. The result is computed in a background thread encapsulated by the Future object, and the result is buffered till it is retrieved.[2]
[edit] Architecture
The main concept in the PFX is a Task, which are small units of code, represented as lambda functions, 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.While and Parallel.Do 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. Each thread, when idle, picks up a batch of Tasks, and puts on its local queue, and then executes them 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.
[edit] See also
[edit] References
- ^ a b c Programming in the Age of Concurrency: Concurrent Programming with PFX. Retrieved on 2007-10-16.
- ^ a b c MSDN Magazine: Task Parallel Library. Retrieved on 2007-10-16.
- ^ a b c June 2008 CTP - Parallel Extensions to the .NET FX. Retrieved on 2008-08-06.
- ^ Parallel Extensions to the .NET FX CTP. Retrieved on 2007-11-30.
- ^ More powerful aggregations in PLINQ. Retrieved on 2008-08-06.

