Parallel Extensions: Difference between revisions

Content deleted Content added
Citation bot (talk | contribs)
m Alter: isbn. Add: citeseerx, pages. | You can use this bot yourself. Report bugs here. | User-activated.
Architecture: Spelling/grammar/punctuation correction
Line 22:
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 [[lambda (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, itIt 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.
 
==See also==