Parallel Extensions

.NET Store APIs
Async model
TPL
EF
WPF
WCF
WF
WCS
The .NET Framework stack

Parallel Extensions was the development name for a managed concurrency library developed by a collaboration between Microsoft Research and the CLR team at Microsoft. The library was released in version 4.0 of the .NET Framework.[1] It is composed of two parts: Parallel LINQ (PLINQ) and Task Parallel Library (TPL).[2][3] It also consists of a set of coordination data structures (CDS) – sets of data structures used to synchronize and co-ordinate the execution of concurrent tasks.[4]

Parallel LINQ

PLINQ, or Parallel 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.[2] 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 uses TPL for execution.[4][5]

Task Parallel Library

The Task Parallel Library (TPL) is the task parallelism component of the Parallel Extensions to .NET.[6] It exposes parallel constructs like parallel For and ForEach loops, using regular method calls and delegates, thus the constructs can be used from any CLI languages. 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,[3] using a work stealing scheduler.[7]

TPL also includes other constructs like Task and Future. A Task is an action that can be executed independent of the rest of the program. In that sense, it is semantically equivalent to a thread, except that it is a more light-weight object and comes without the overhead of creating an OS thread. Tasks are queued by a Task Manager object and are scheduled to run on multiple OS threads in a thread pool when their turn comes.

Future is a task that returns a result. The result is computed in a background thread encapsulated by the Future object, and the result is buffered until it is retrieved.[3] If an attempt is made to retrieve the result before it has been computed then the requesting thread will block until the result is available.[6]

The other construct of TPL is Parallel class. TPL provides a basic form of structured parallelism via three static methods in the Parallel class:

Parallel.Invoke
Executes an array of Action delegates in parallel, and then waits for them to complete
Parallel.For
Parallel equivalent of a C# for loop
Parallel.ForEach
Parallel equivalent of a C# foreach loop

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. 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.

See also

References

  1. ^ "What's New in the .NET Framework 4". Retrieved 21 September 2011.
  2. ^ a b "Programming in the Age of Concurrency: Concurrent Programming with PFX". Retrieved 16 October 2007.
  3. ^ a b c "MSDN Magazine: Task Parallel Library". Archived from the original on 14 October 2007. Retrieved 16 October 2007.
  4. ^ a b "June 2008 CTP – Parallel Extensions to the .NET FX". Retrieved 6 August 2008.
  5. ^ "More powerful aggregations in PLINQ". Retrieved 6 August 2008.
  6. ^ a b Duffy, Joe (2009). Concurrent Programming on Windows. pp. 887–929. ISBN 978-0321434821.
  7. ^ Leijen, Daan; Schulte, Wolfram; Burckhardt, Sebastian (2009). "The Design of a Task Parallel Library". ACM SIGPLAN Notices. 44 (10): 227. CiteSeerX 10.1.1.146.4197. doi:10.1145/1639949.1640106.

Read other articles:

An-Nazla al-YamaniyaLingkunganNegaraArab SaudiProvinsiProvinsi MakkahPemerintahan • Wali kotaHani Abu Ras[1] • Gubernur kotaMish'al Al-SaudKetinggian12 m (39 ft)Populasi (2014)[2] • Total3.976.000Zona waktuUTC+3 (AST) • Musim panas (DST)ASTKode pos(5 kode digit dimulai dari 23; e.g. 23434)Kode area telepon+966-12Situs webwww.jeddah.gov.sa/english/index.php An-Nazla al-Yamaniya adalah sebuah pemukiman padat penduduk...

 

Municipal building in Drogheda, Ireland The Tholsel, DroghedaHalla an BhaileThe Tholsel, DroghedaThe TholselLocation within IrelandGeneral informationArchitectural styleNeoclassical styleAddressWest StreetTown or cityDroghedaCountryIrelandCoordinates53°42′53″N 6°21′02″W / 53.7148°N 6.3505°W / 53.7148; -6.3505Completed1770Design and constructionArchitect(s)George Darley The Tholsel (Irish: Halla an Bhaile)[1] is a municipal building in West Street, D...

 

У этого термина существуют и другие значения, см. Индукция. Схема классического представления связи между теорией, эмпиризмом, индукцией и дедукцией. Инду́кция (лат. inductio — наведение, от лат. inducere — влечь за собой, установить) — умозаключение от фактов к неко...

قرية باينبريدج   الإحداثيات 42°17′41″N 75°28′48″W / 42.2947°N 75.48°W / 42.2947; -75.48  [1] تاريخ التأسيس 1789  تقسيم إداري  البلد الولايات المتحدة[2]  التقسيم الأعلى مقاطعة تشينانغو  خصائص جغرافية  المساحة 3.50583 كيلومتر مربع3.298752 كيلومتر مربع (1 أبريل 2010)  ...

 

2021 studio album by Shannon NollRawStudio album by Shannon NollReleased28 May 2021Length48:39LabelRed DogShannon Noll chronology Unbroken(2018) Raw(2021) Singles from Raw Long Live the SummerReleased: 4 November 2019[1] WonderfulReleased: 20 November 2020[2] BetterReleased: 23 April 2021[3] Raw is the sixth studio album by Australian singer-songwriter Shannon Noll. Upon release, Noll said the album features some new songs plus new recordings of many of the so...

 

Congregation of Saint Michael the ArchangelCongregatio Sancti Michaelis ArchangeliAbbreviationCSMANicknameMichaelites[1]Formation1921; 103 years ago (1921)FounderBlessed Fr. Bronisław Bonawentura Markiewicz, SDBTypeClerical Religious Congregation of Pontifical Right for menHeadquartersUl. Marszalka Józefa Pilsudskiego 248/252, 05-261 Marki-Struga, PolandCoordinates41°54′4.9″N 12°27′38.2″E / 41.901361°N 12.460611°E / 41.901361; 12...

Mostowfi ol-Mamalek Perdana Menteri IranMasa jabatan15 Juli 1910 – 19 Juli 1911Penguasa monarkiAhmad Shah QajarPendahuluVosough od-DowlehPenggantiVosough od-DowlehMasa jabatan1 Juli 1914 – 1 Februari 1915Penguasa monarkiAhmad Shah QajarPendahuluMirza Mohammed Ali KhanPenggantiAbdol-Hossein Mirza FarmanfarmaMasa jabatan18 Agustus 1915 – 25 Desember 1915Penguasa monarkiAhmad Shah QajarPendahuluAbdol Majid MirzaPenggantiAbdol-Hossein Mirza FarmanfarmaMasa jabatan...

 

Socrates' explation to Glaucon that souls must be immortal A Renaissance manuscript Latin translation of The Republic The Myth of Er (/ɜːr/; Greek: Ἤρ, translit. ér, gen.: Ἠρός) is a legend that concludes Plato's Republic (10.614–10.621). The story includes an account of the cosmos and the afterlife that greatly influenced religious, philosophical, and scientific thought for many centuries. The story begins as a man named Er, son of Armenios (Ἀρμένιος), of Pamphylia...

 

This article includes a list of references, related reading, or external links, but its sources remain unclear because it lacks inline citations. Please help improve this article by introducing more precise citations. (March 2024) (Learn how and when to remove this message) Charles Thomas Thomas (Master stone carver)BornJuly 26, 1820London, EnglandDiedDecember 25, 1867Quincy, Illinois, USANationalityEnglishOccupationArchitectPracticeCharles T. ThomasProjectsRoyal Navy Dockyard (Hamilton, Berm...

Complex of thunderstorms organized on a larger scale A shelf cloud such as this one can be a sign that a squall is imminent A mesoscale convective system (MCS) is a complex of thunderstorms that becomes organized on a scale larger than the individual thunderstorms but smaller than extratropical cyclones, and normally persists for several hours or more. A mesoscale convective system's overall cloud and precipitation pattern may be round or linear in shape, and include weather systems such as t...

 

Map all coordinates using OpenStreetMap Download coordinates as: KML GPX (all coordinates) GPX (primary coordinates) GPX (secondary coordinates) Town in Queensland, AustraliaRomaQueenslandAerial view of RomaRomaCoordinates26°34′24″S 148°47′13″E / 26.5733°S 148.7869°E / -26.5733; 148.7869 (Roma (town centre))Population6,838 (2021)[1] • Density87.55/km2 (226.76/sq mi)Established1867Postcode(s)4455[2]Elevation299.4...

 

Questa voce o sezione sull'argomento trattati non cita le fonti necessarie o quelle presenti sono insufficienti. Puoi migliorare questa voce aggiungendo citazioni da fonti attendibili secondo le linee guida sull'uso delle fonti. Trattato di NišContestoFine della guerra russo-turca del 1735-1739. Firma3 ottobre 1739 LuogoNiš Parti Impero ottomano Impero russo voci di trattati presenti su Wikipedia Il trattato di Nyssa fu stipulato il 3 ottobre 1739 a Niš (nell'odierna Serbia) fra...

この項目には、一部のコンピュータや閲覧ソフトで表示できない文字が含まれています(詳細)。 数字の大字(だいじ)は、漢数字の一種。通常用いる単純な字形の漢数字(小字)の代わりに同じ音の別の漢字を用いるものである。 概要 壱万円日本銀行券(「壱」が大字) 弐千円日本銀行券(「弐」が大字) 漢数字には「一」「二」「三」と続く小字と、「壱」「�...

 

муниципальный районРоссошанский район Флаг Герб 50°10′00″ с. ш. 39°35′00″ в. д.HGЯO Страна  Россия Входит в Воронежскую область Включает 18 муниципальных образований Адм. центр город Россошь Глава администрации Мишанков Юрий Валентинович Глава района Сисюк ...

 

List of events ← 1940 1939 1938 1937 1936 1941 in Ireland → 1942 1943 1944 1945 1946 Centuries: 18th 19th 20th 21st Decades: 1920s 1930s 1940s 1950s 1960s See also:1941 in Northern IrelandOther events of 1941List of years in Ireland Events from the year 1941 in Ireland. Incumbents President: Douglas Hyde Taoiseach: Éamon de Valera (FF) Tánaiste: Seán T. O'Kelly (FF) Minister for Finance: Seán T. O'Kelly (FF) Chief Justice: Timothy Sullivan Dáil: 10th Seanad: 3rd Events 2 Jan...

  关于与「內閣總理大臣」標題相近或相同的条目页,請見「內閣總理大臣 (消歧義)」。 日本國內閣總理大臣內閣總理大臣紋章現任岸田文雄自2021年10月4日在任尊称總理、總理大臣、首相、阁下官邸總理大臣官邸提名者國會全體議員選出任命者天皇任期四年,無連任限制[註 1]設立法源日本國憲法先前职位太政大臣(太政官)首任伊藤博文设立1885年12月22日,...

 

ريكسداغ الطبقاتمعلومات عامةالبداية 1527 البلد السويد الاختصاص السويد حل محله Swedish bicameral parliament (en) Diet of Finland (en) (1809) حلَّ محل Herredag (fr) تاريخ الحل أو الإلغاء أو الهدم 1866 تعديل - تعديل مصدري - تعديل ويكي بيانات ريكسداغ الطبقات (بالسويدية Ståndsriksdagen) اسم كان يطلق على الطبقات في مملكة ال�...

 

Duel Borussia Dortmund melawan FC Schalke 04 pada 2009. Revierderby atau juga dikenal dengan nama Derby Lembah Ruhr adalah persaingan dan permusuhan antara dua klub sepak bola, yakni Borussia Dortmund dan FC Schalke 04.[1] Dinamakan derby Sungai Ruhr karena dua klub tersebut mendiami kawasan Ruhr, Jerman. Akar persaingan dan permusuhan Dortmund dan Schalke dapat ditarik hingga latar belakang sejarahnya yang sebenarnya tidak terlalu kontras. Baik Dortmund maupun Schalke tidak memiliki ...

Space Innovation and Growth TeamFormationJune 26, 2009 (2009-06-26)DissolvedFebruary 10, 2010 (2010-02-10)PurposeStrategic planning of the UK space industryMain organExecutive Steering BoardParent organizationBISAffiliationsVirgin Galactic, Surrey Satellite Technology, Astrium, Technology Strategy Board, Avanti Communications, Imperial College London, Broadband Stakeholder Group The Space Innovation and Growth Team (also known as the Space IGT) was a joint initi...

 

إنليل𒀭𒂗𒆤 تمثال صغير لإنيل جالسًا على عرشه في نفر، يقدّر تاريخه بين 1600 و1800 قبل الميلاد ويعرض اليوم في المتحف العراقي زوجات ننهورساجنينليلارشكيجال  الأب أنو  ذرية نينورتا،  وسين،  وأداد،  وبابيلساغ،  ونيرغال،  ونمتار  تعديل مصدري - تعديل   جزء من سل...