.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.
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
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
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
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.
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
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)
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
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
Parallel Programming Architecture
architecture diagram explains in detail on how the parallel processing
will takes and gets scheduled based on the needs. The main components of
this architecture are as follow.
- Ã‚Â· Task Parallel Library
- Ã‚Â· Parallel LINQ (PLINQ)
- Ã‚Â· Task Schedulers
- Ã‚Â· Lambda Expressions in PLINQ
We will get into detail of each component and see how the process takes place in each component in the next upcoming article.