SlideShare a Scribd company logo
Parallel Extensions in .Net 4.0Dmytro Maleev for Lviv.Net User Group
AgendaКуда катится мир?Hello, Parallel Extensions!Parallel vs MultithreadingParallel LoopsTasksPLINQCDS & Thread EnchantmentsReferencesQ&A
Куда катится мирForget about CPU frequency increase! There are a lot of issues with this, which will be fixed in future!1998 Intel 8048680Mhz1 Core2007Core 2 Duo 2.13 GHz2 Core2000Celeron 400Mhz1 Core2010Intel i5 3.3GHz2 Core 4 Threads2003Athlon XP 1.6+GHz1 Core?
Куда катится мирFor now…ENLARGE YOUR…CPU CORE COUNT!PENPEN
Hello, Parallel Extensions!Parallel Extensions, previously known as the Parallel Framework Extensions or PFX, is a managed concurrency library being developed by a collaboration between Microsoft Research and the CLR team at Microsoft. It is composed of two parts: Parallel LINQ (PLINQ) andTask Parallel Library (TPL).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.Thelibrary was released as a CTP on November 29, 2007and refreshed again in December 2007 and June 2008. Microsoft has announced that the Parallel Extensions to .NET will release as part of the .NET 4.0 Framework release.©Wikipedia
Hello, Parallel Extensions!Visual Studio Debugging and profiling supportParallel ExtensionsPLINQTask Parallel LibraryTask SchedulerCDS
Parallel vs MultithreadingMultithreaded!=parallelization“ If on a single core machine you are using threads and it makes perfect sense for your scenario, then you are not "doing parallelism", you are just doing multithreading””On a single core you can use threads and you can have concurrency, but to achieveparallelism on a multi-core box you have to identify in your code the exploitableconcurrency: the portions of your code that can truly run at the same time.”Daniel Moth
Parallel vs Multithreading
Dark Side of Paprallelization and MultithreadingRace conditionshttp://en.wikipedia.org/wiki/Race_condition2.	Deadlockshttp://en.wikipedia.org/wiki/Deadlockhttp://en.wikipedia.org/wiki/Dining_philosophers_problemThread starvationDifficult to code and debugEnvironmental
Народная мудрость!
Parallel LoopsParallel.For()Parallel.For(0, 100, i =>            {                Console.WriteLine("This is I-I-I-I-I-I: {0}", i);            });Parallel.ForEach()Parallel.ForEach(ThisIsCollection, collectionItem =>{collectionItem.Hello();});Parallel OptionsParallel.Invoke()
Parallel Loops. Use Force wisely!Parallelization Can Hurt Performancehttp://msdn.microsoft.com/en-us/library/dd560853(VS.100).aspxhttp://en.wikipedia.org/wiki/Context_switch
DEMOAntiSocialRobots
Task - Task SchedulerTask is a new class that represents the work you want completed. There are methods to create,  schedule, and synchronize tasks in your application.Tasks are controlled by task scheduler.Tasks scheduler works with thread pool.
Task In DeepTasks can:Task can be createdTask can wait! Task can simply Wait(), WaitAll() or WaitAny().Task knows when it is completed ( IsCompleted property)Task can ContinueWith()Task can return valueTask has Options and Status
DemoStrassen algorithm
PLINQPLINQ is just parallelized version of LINQNot parallelized: LINQ-to-SQL & LINQ-to-Entity.LINQ:var query = from s in someCollectionlet result = CoolService.CallService(s)select result;PLINQ:varquery = from s in someCollection.AsParallel()let result = CoolService.CallService(s)select result;
PLINQ. How it works?
PLINQ. Overview	Ordering ResultsAsOrdered()ForAll Operator()AsSequential()WithMergeOptionsParallel Performance Analyzer. Just for rich
DEMO	Baby Names
CDS & Thread EnchantmentsThread Enchantments:Thread.Yield()Monitor.Enter()Concurrent CollectionsConcurrentStack (LIFO)ConcurrentQueue (FIFO)ConcurrentDictionaryConcurrentBagBlockingCollection
Synchronization PrimitivesBarrier“Let’s meet near monument and then go to have a beer”Cancellation TokensCountDownEventManualResetEventSlim and SemaphoreSlimSpinLockThreadLocal<T>
References	Parallel Programming with .NEThttp://blogs.msdn.com/b/pfxteam/Wikihttp://en.wikipedia.org/wiki/Parallel_ExtensionsIntroducing .NET 4.0http://www.amazon.com/Introducing-NET-4-0-Visual-Experts/dp/143022455XLviv.Net User Grouphttp://dotnetug-lviv.blogspot.com/
Q&A?
If you still have a questions	Mail me:diwingless@gmail.comSkype me:hmmidmaTwitter:dimko1
Ad

More Related Content

Similar to Parallel extensions in .Net 4.0 (20)

MTaulty_DevWeek_Parallel
MTaulty_DevWeek_ParallelMTaulty_DevWeek_Parallel
MTaulty_DevWeek_Parallel
ukdpe
 
Parallel Extentions to the .NET Framework
Parallel Extentions to the .NET FrameworkParallel Extentions to the .NET Framework
Parallel Extentions to the .NET Framework
ukdpe
 
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go WrongJDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
PROIDEA
 
Here comes the Loom - Ya!vaConf.pdf
Here comes the Loom - Ya!vaConf.pdfHere comes the Loom - Ya!vaConf.pdf
Here comes the Loom - Ya!vaConf.pdf
Krystian Zybała
 
Clustering van IT-componenten
Clustering van IT-componentenClustering van IT-componenten
Clustering van IT-componenten
Richard Claassens CIPPE
 
Parallel Computing For Managed Developers
Parallel Computing For Managed DevelopersParallel Computing For Managed Developers
Parallel Computing For Managed Developers
Bala Subra
 
Devoxx
DevoxxDevoxx
Devoxx
Martin Odersky
 
Getting started with Clojure
Getting started with ClojureGetting started with Clojure
Getting started with Clojure
John Stevenson
 
ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in...
 ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in... ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in...
ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in...
Saurabh Nanda
 
DotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETDotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NET
Maarten Balliauw
 
Oscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simpleOscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simple
Martin Odersky
 
JVM in the Age of AI: Babylon, Valhalla, TornadoVM and friends
JVM in the Age of AI: Babylon, Valhalla, TornadoVM and friendsJVM in the Age of AI: Babylon, Valhalla, TornadoVM and friends
JVM in the Age of AI: Babylon, Valhalla, TornadoVM and friends
Artur Skowroński
 
Exploring .NET memory management - JetBrains webinar
Exploring .NET memory management - JetBrains webinarExploring .NET memory management - JetBrains webinar
Exploring .NET memory management - JetBrains webinar
Maarten Balliauw
 
Using spl tools in your code
Using spl tools in your codeUsing spl tools in your code
Using spl tools in your code
Elizabeth Smith
 
Thinking in parallel ab tuladev
Thinking in parallel ab tuladevThinking in parallel ab tuladev
Thinking in parallel ab tuladev
Pavel Tsukanov
 
Optimizing Application Architecture (.NET/Java topics)
Optimizing Application Architecture (.NET/Java topics)Optimizing Application Architecture (.NET/Java topics)
Optimizing Application Architecture (.NET/Java topics)
Ravi Okade
 
Sparklife - Life In The Trenches With Spark
Sparklife - Life In The Trenches With SparkSparklife - Life In The Trenches With Spark
Sparklife - Life In The Trenches With Spark
Ian Pointer
 
Parallel Programming: Beyond the Critical Section
Parallel Programming: Beyond the Critical SectionParallel Programming: Beyond the Critical Section
Parallel Programming: Beyond the Critical Section
Tony Albrecht
 
SQL Server In-Memory OLTP introduction (Hekaton)
SQL Server In-Memory OLTP introduction (Hekaton)SQL Server In-Memory OLTP introduction (Hekaton)
SQL Server In-Memory OLTP introduction (Hekaton)
Shy Engelberg
 
Hadoop Performance Optimization at Scale, Lessons Learned at Twitter
Hadoop Performance Optimization at Scale, Lessons Learned at TwitterHadoop Performance Optimization at Scale, Lessons Learned at Twitter
Hadoop Performance Optimization at Scale, Lessons Learned at Twitter
DataWorks Summit
 
MTaulty_DevWeek_Parallel
MTaulty_DevWeek_ParallelMTaulty_DevWeek_Parallel
MTaulty_DevWeek_Parallel
ukdpe
 
Parallel Extentions to the .NET Framework
Parallel Extentions to the .NET FrameworkParallel Extentions to the .NET Framework
Parallel Extentions to the .NET Framework
ukdpe
 
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go WrongJDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
PROIDEA
 
Here comes the Loom - Ya!vaConf.pdf
Here comes the Loom - Ya!vaConf.pdfHere comes the Loom - Ya!vaConf.pdf
Here comes the Loom - Ya!vaConf.pdf
Krystian Zybała
 
Parallel Computing For Managed Developers
Parallel Computing For Managed DevelopersParallel Computing For Managed Developers
Parallel Computing For Managed Developers
Bala Subra
 
Getting started with Clojure
Getting started with ClojureGetting started with Clojure
Getting started with Clojure
John Stevenson
 
ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in...
 ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in... ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in...
ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in...
Saurabh Nanda
 
DotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETDotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NET
Maarten Balliauw
 
Oscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simpleOscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simple
Martin Odersky
 
JVM in the Age of AI: Babylon, Valhalla, TornadoVM and friends
JVM in the Age of AI: Babylon, Valhalla, TornadoVM and friendsJVM in the Age of AI: Babylon, Valhalla, TornadoVM and friends
JVM in the Age of AI: Babylon, Valhalla, TornadoVM and friends
Artur Skowroński
 
Exploring .NET memory management - JetBrains webinar
Exploring .NET memory management - JetBrains webinarExploring .NET memory management - JetBrains webinar
Exploring .NET memory management - JetBrains webinar
Maarten Balliauw
 
Using spl tools in your code
Using spl tools in your codeUsing spl tools in your code
Using spl tools in your code
Elizabeth Smith
 
Thinking in parallel ab tuladev
Thinking in parallel ab tuladevThinking in parallel ab tuladev
Thinking in parallel ab tuladev
Pavel Tsukanov
 
Optimizing Application Architecture (.NET/Java topics)
Optimizing Application Architecture (.NET/Java topics)Optimizing Application Architecture (.NET/Java topics)
Optimizing Application Architecture (.NET/Java topics)
Ravi Okade
 
Sparklife - Life In The Trenches With Spark
Sparklife - Life In The Trenches With SparkSparklife - Life In The Trenches With Spark
Sparklife - Life In The Trenches With Spark
Ian Pointer
 
Parallel Programming: Beyond the Critical Section
Parallel Programming: Beyond the Critical SectionParallel Programming: Beyond the Critical Section
Parallel Programming: Beyond the Critical Section
Tony Albrecht
 
SQL Server In-Memory OLTP introduction (Hekaton)
SQL Server In-Memory OLTP introduction (Hekaton)SQL Server In-Memory OLTP introduction (Hekaton)
SQL Server In-Memory OLTP introduction (Hekaton)
Shy Engelberg
 
Hadoop Performance Optimization at Scale, Lessons Learned at Twitter
Hadoop Performance Optimization at Scale, Lessons Learned at TwitterHadoop Performance Optimization at Scale, Lessons Learned at Twitter
Hadoop Performance Optimization at Scale, Lessons Learned at Twitter
DataWorks Summit
 

More from Dima Maleev (17)

Mems
MemsMems
Mems
Dima Maleev
 
JavaScript in Mobile Development
JavaScript in Mobile DevelopmentJavaScript in Mobile Development
JavaScript in Mobile Development
Dima Maleev
 
What is new in Angular 2.0
What is new in Angular 2.0What is new in Angular 2.0
What is new in Angular 2.0
Dima Maleev
 
Fear and Loathing at PhoneGap
Fear and Loathing at PhoneGapFear and Loathing at PhoneGap
Fear and Loathing at PhoneGap
Dima Maleev
 
Development Applications for Chrome OS
Development Applications for Chrome OSDevelopment Applications for Chrome OS
Development Applications for Chrome OS
Dima Maleev
 
Mobile for JS Developer
Mobile for JS DeveloperMobile for JS Developer
Mobile for JS Developer
Dima Maleev
 
Gamification
GamificationGamification
Gamification
Dima Maleev
 
Development Application for Windows 8 by Eugene Kiriyan
Development Application for Windows 8 by Eugene KiriyanDevelopment Application for Windows 8 by Eugene Kiriyan
Development Application for Windows 8 by Eugene Kiriyan
Dima Maleev
 
.NET MicroFramework by Yulian Slobodyan
.NET MicroFramework by Yulian Slobodyan.NET MicroFramework by Yulian Slobodyan
.NET MicroFramework by Yulian Slobodyan
Dima Maleev
 
Modern mobile development overview
Modern mobile development overviewModern mobile development overview
Modern mobile development overview
Dima Maleev
 
Go mobile with Windows Phone
Go mobile with Windows PhoneGo mobile with Windows Phone
Go mobile with Windows Phone
Dima Maleev
 
Lviv .Net User Group. NHibernate
Lviv .Net User Group. NHibernateLviv .Net User Group. NHibernate
Lviv .Net User Group. NHibernate
Dima Maleev
 
Time. To manage, or not to manage
Time. To manage, or not to manageTime. To manage, or not to manage
Time. To manage, or not to manage
Dima Maleev
 
Создание SharePoint 2010 решений в Visual Studio
Создание SharePoint 2010 решений в Visual StudioСоздание SharePoint 2010 решений в Visual Studio
Создание SharePoint 2010 решений в Visual Studio
Dima Maleev
 
24000 Days Of UX
24000 Days Of UX24000 Days Of UX
24000 Days Of UX
Dima Maleev
 
Developing silverlight applications for windows phone 7 series
Developing silverlight applications for windows phone 7 seriesDeveloping silverlight applications for windows phone 7 series
Developing silverlight applications for windows phone 7 series
Dima Maleev
 
New Features Of ASP.Net 4 0
New Features Of ASP.Net 4 0New Features Of ASP.Net 4 0
New Features Of ASP.Net 4 0
Dima Maleev
 
JavaScript in Mobile Development
JavaScript in Mobile DevelopmentJavaScript in Mobile Development
JavaScript in Mobile Development
Dima Maleev
 
What is new in Angular 2.0
What is new in Angular 2.0What is new in Angular 2.0
What is new in Angular 2.0
Dima Maleev
 
Fear and Loathing at PhoneGap
Fear and Loathing at PhoneGapFear and Loathing at PhoneGap
Fear and Loathing at PhoneGap
Dima Maleev
 
Development Applications for Chrome OS
Development Applications for Chrome OSDevelopment Applications for Chrome OS
Development Applications for Chrome OS
Dima Maleev
 
Mobile for JS Developer
Mobile for JS DeveloperMobile for JS Developer
Mobile for JS Developer
Dima Maleev
 
Development Application for Windows 8 by Eugene Kiriyan
Development Application for Windows 8 by Eugene KiriyanDevelopment Application for Windows 8 by Eugene Kiriyan
Development Application for Windows 8 by Eugene Kiriyan
Dima Maleev
 
.NET MicroFramework by Yulian Slobodyan
.NET MicroFramework by Yulian Slobodyan.NET MicroFramework by Yulian Slobodyan
.NET MicroFramework by Yulian Slobodyan
Dima Maleev
 
Modern mobile development overview
Modern mobile development overviewModern mobile development overview
Modern mobile development overview
Dima Maleev
 
Go mobile with Windows Phone
Go mobile with Windows PhoneGo mobile with Windows Phone
Go mobile with Windows Phone
Dima Maleev
 
Lviv .Net User Group. NHibernate
Lviv .Net User Group. NHibernateLviv .Net User Group. NHibernate
Lviv .Net User Group. NHibernate
Dima Maleev
 
Time. To manage, or not to manage
Time. To manage, or not to manageTime. To manage, or not to manage
Time. To manage, or not to manage
Dima Maleev
 
Создание SharePoint 2010 решений в Visual Studio
Создание SharePoint 2010 решений в Visual StudioСоздание SharePoint 2010 решений в Visual Studio
Создание SharePoint 2010 решений в Visual Studio
Dima Maleev
 
24000 Days Of UX
24000 Days Of UX24000 Days Of UX
24000 Days Of UX
Dima Maleev
 
Developing silverlight applications for windows phone 7 series
Developing silverlight applications for windows phone 7 seriesDeveloping silverlight applications for windows phone 7 series
Developing silverlight applications for windows phone 7 series
Dima Maleev
 
New Features Of ASP.Net 4 0
New Features Of ASP.Net 4 0New Features Of ASP.Net 4 0
New Features Of ASP.Net 4 0
Dima Maleev
 
Ad

Recently uploaded (20)

How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Library Association of Ireland
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
SPRING FESTIVITIES - UK AND USA -
SPRING FESTIVITIES - UK AND USA            -SPRING FESTIVITIES - UK AND USA            -
SPRING FESTIVITIES - UK AND USA -
Colégio Santa Teresinha
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Library Association of Ireland
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
Ad

Parallel extensions in .Net 4.0

  • 1. Parallel Extensions in .Net 4.0Dmytro Maleev for Lviv.Net User Group
  • 2. AgendaКуда катится мир?Hello, Parallel Extensions!Parallel vs MultithreadingParallel LoopsTasksPLINQCDS & Thread EnchantmentsReferencesQ&A
  • 3. Куда катится мирForget about CPU frequency increase! There are a lot of issues with this, which will be fixed in future!1998 Intel 8048680Mhz1 Core2007Core 2 Duo 2.13 GHz2 Core2000Celeron 400Mhz1 Core2010Intel i5 3.3GHz2 Core 4 Threads2003Athlon XP 1.6+GHz1 Core?
  • 4. Куда катится мирFor now…ENLARGE YOUR…CPU CORE COUNT!PENPEN
  • 5. Hello, Parallel Extensions!Parallel Extensions, previously known as the Parallel Framework Extensions or PFX, is a managed concurrency library being developed by a collaboration between Microsoft Research and the CLR team at Microsoft. It is composed of two parts: Parallel LINQ (PLINQ) andTask Parallel Library (TPL).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.Thelibrary was released as a CTP on November 29, 2007and refreshed again in December 2007 and June 2008. Microsoft has announced that the Parallel Extensions to .NET will release as part of the .NET 4.0 Framework release.©Wikipedia
  • 6. Hello, Parallel Extensions!Visual Studio Debugging and profiling supportParallel ExtensionsPLINQTask Parallel LibraryTask SchedulerCDS
  • 7. Parallel vs MultithreadingMultithreaded!=parallelization“ If on a single core machine you are using threads and it makes perfect sense for your scenario, then you are not "doing parallelism", you are just doing multithreading””On a single core you can use threads and you can have concurrency, but to achieveparallelism on a multi-core box you have to identify in your code the exploitableconcurrency: the portions of your code that can truly run at the same time.”Daniel Moth
  • 9. Dark Side of Paprallelization and MultithreadingRace conditionshttp://en.wikipedia.org/wiki/Race_condition2. Deadlockshttp://en.wikipedia.org/wiki/Deadlockhttp://en.wikipedia.org/wiki/Dining_philosophers_problemThread starvationDifficult to code and debugEnvironmental
  • 11. Parallel LoopsParallel.For()Parallel.For(0, 100, i => { Console.WriteLine("This is I-I-I-I-I-I: {0}", i); });Parallel.ForEach()Parallel.ForEach(ThisIsCollection, collectionItem =>{collectionItem.Hello();});Parallel OptionsParallel.Invoke()
  • 12. Parallel Loops. Use Force wisely!Parallelization Can Hurt Performancehttp://msdn.microsoft.com/en-us/library/dd560853(VS.100).aspxhttp://en.wikipedia.org/wiki/Context_switch
  • 14. Task - Task SchedulerTask is a new class that represents the work you want completed. There are methods to create, schedule, and synchronize tasks in your application.Tasks are controlled by task scheduler.Tasks scheduler works with thread pool.
  • 15. Task In DeepTasks can:Task can be createdTask can wait! Task can simply Wait(), WaitAll() or WaitAny().Task knows when it is completed ( IsCompleted property)Task can ContinueWith()Task can return valueTask has Options and Status
  • 17. PLINQPLINQ is just parallelized version of LINQNot parallelized: LINQ-to-SQL & LINQ-to-Entity.LINQ:var query = from s in someCollectionlet result = CoolService.CallService(s)select result;PLINQ:varquery = from s in someCollection.AsParallel()let result = CoolService.CallService(s)select result;
  • 18. PLINQ. How it works?
  • 19. PLINQ. Overview Ordering ResultsAsOrdered()ForAll Operator()AsSequential()WithMergeOptionsParallel Performance Analyzer. Just for rich
  • 21. CDS & Thread EnchantmentsThread Enchantments:Thread.Yield()Monitor.Enter()Concurrent CollectionsConcurrentStack (LIFO)ConcurrentQueue (FIFO)ConcurrentDictionaryConcurrentBagBlockingCollection
  • 22. Synchronization PrimitivesBarrier“Let’s meet near monument and then go to have a beer”Cancellation TokensCountDownEventManualResetEventSlim and SemaphoreSlimSpinLockThreadLocal<T>
  • 23. References Parallel Programming with .NEThttp://blogs.msdn.com/b/pfxteam/Wikihttp://en.wikipedia.org/wiki/Parallel_ExtensionsIntroducing .NET 4.0http://www.amazon.com/Introducing-NET-4-0-Visual-Experts/dp/143022455XLviv.Net User Grouphttp://dotnetug-lviv.blogspot.com/
  • 24. Q&A?
  • 25. If you still have a questions Mail me:[email protected] me:hmmidmaTwitter:dimko1