Parallel Extensions: Difference between revisions

Content deleted Content added
m Image: --> File:
Codename Lisa (talk | contribs)
Line 1:
{{Use dmy dates|date=May 2013}}
[[File:DotNet.svg|thumb|right|250px|The [[.NET Framework]] stack.]]
'''Parallel Extensions''' was the development name for a [[Managed code|managed]] [[Concurrent programming|concurrency]] [[Library (computing)|library]] developed by a collaboration between [[Microsoft Research]] and the [[Common Language Runtime|CLR]] team at [[Microsoft]]. The library was released in version 4.0 of the [[.NET Framework]].<ref>{{cite web | url = http://msdn.microsoft.com/en-us/library/ms171868.aspx#parallel_computing | title = What's New in the .NET Framework 4 | accessdate = 2011-09-21}}</ref> It is composed of two parts: [[#Parallel LINQ|''Parallel LINQ'']] (PLINQ) and [[#Task Parallel Library|''Task Parallel Library'']] (TPL).<ref name="channel9">{{cite web | url = http://channel9.msdn.com/Showpost.aspx?postid=347531 | title = Programming in the Age of Concurrency: Concurrent Programming with PFX | accessdate = 2007-10-16}}</ref><ref name="msdnmag">{{cite web | url = http://msdn.microsoft.com/msdnmag/issues/07/10/Futures/default.aspx | title = MSDN Magazine: Task Parallel Library | accessdate = 2007-10-16}}</ref> It also consists of a set of ''coordination data structures'' (CDS) – sets of [[data structure]]s used to synchronize and co-ordinate the execution of concurrent tasks.<ref name="somajune"/>
 
Line 21:
 
==Architecture==
The main concept in the Parallel Extensions to .NET is a <code>Task</code>, which is a small unit of code, usually represented as a [[Lambdalambda expression(programming)|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 <code>Parallel.For</code>, <code>Parallel.ForEach</code> and <code>Parallel.Invoke</code> methods divide a loop into Tasks.
 
PFX includes a <code>Task Manager</code> object which schedules the Tasks for execution. A Task Manager contains a global [[queue (data structure)|queue]] of Tasks, which are then executed. In addition, it also encapsulates multiple [[Thread (computing)|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.
Line 30:
*[[Cilk]] - comparable technology for C and C++
*[[Grand Central Dispatch]] - comparable technology in [[Mac OS X 10.6]] developed by [[Apple Inc.|Apple]].
*[[Java Concurrency]] - comparable technology in [[Java (software platform)|Java]] (also known as [[JSR]] 166]]).
*[[Intel Threading Building Blocks]] - comparable technology for C++ available for many systems created originally by Intel (also open source)
*[[Thread pool pattern]]