Parallel Processing in Visual Studio 2010

Introduction

The .net framework 4.0 introduces a new programming architecture for doing multiple processes asynchronously that greatly simplifies the application load and gets better performance. The new programming architecture helps developers to write a scalable and more efficient code in order to achieve better performance for the application development. Parallel LINQ (PLINQ) which is a parallel implementation of LINQ to Objects enables similar functionality for the developers through declarative coding.

[more]

You can have in your mind how multi core processor is related with multi threaded application. The concept would be like application development processes based on the environment the application is running. Even though the application runs in multi core processor, fewer resources will be taken by the application to run the process. Say for example multi core processor has the ability to handle n number of process; code will work step by step in any one of the processor leaving remain processor unused. Now the developers can make use of this particularly when working on complex algorithms or in case of need to handle multiple processes asynchronously.

Multi threaded programming is one of the way which gives developers an option to work with multiple threads concurrently. Even though this concept is been available since .net 1.1, its been avoided due to the complexity and developers need to write clean code in order to get performance using Multi threaded concept rather spending most of the time with business and functionality.

Using Normal Process

Consider a real time example of a web page having a Tab Control, as per the normal programming each tab will be loaded sequentially as per the business and not in parallel. Definitely it takes more time to load the contents to different tabs from each data source.

Using Parallel Process

Normal processing uses only a single processor even though the other processors are idle over there. But when using parallel processing (using Parallel Library) the other processors are also used to execute the core functionality which gives application a much performance.

Finally Multi Threaded application works on both multi core and also on a single core processor as it’s based on the hardware configuration. Underneath the code will be working on the single thread if it goes to a single processor and multiple threads if it goes to a multi processor.

Concurrent Processing vs Parallel Processing

Concurrent Processing

In Concurrent programming several streams of functionality may be executed concurrently. Each one of the functionality operated in a sequential order process except that it communicate and interfere with one another. For Example: Two thread tasks Task1 and Task2 are concurrent if the order in which the tasks are executed is not predetermined. The possible execution is as follows.

Task1 may be executed and completed before Task2

Task2 may be executed and completed before Task1

Task1 and Task2 may need to be executed alternatively

Task1 and Task2 may be executed and completed simultaneously at the same time period (Parallelism)

Parallel Processing

In parallel Programming, it’s the process of executing the functionality by dividing into sub functionalities that are to be operated as concurrent programs. For Example: If two concurrent thread tasks are scheduled to run by OS and if these threads run on a single core processor we will get concurrency if the same is running on a multi core processor we will get parallelism.

So we can’t say which is more efficient programming that the other, but neither is the superset of the other programming process. Based on the business requirement the processor can be selected and used in the application development process.

Author

Karthikeyan Anbarasan, Microsoft MVP (Most Valuable Professional) in ASP.NET/IIS Architecture. He is the Founder and Chief Editor of the www.f5debug.net website and has authored books on Windows Phone and Business Intelligence(SSIS). He is also a Passionate Speaker and a Blogger on Microsoft Technologies.

Site Counter

Awards

Disclaimer

This is a personal weblog. The opinions expressed here represent my own and not those of my employer. For accuracy and official reference refer to MSDN/ TechNet. I have documented my personal experience on this blog.