• Parallel Processing Won’t Make Your Apps Faster

    One of the common misconceptions around multithreaded applications is that adding more threads to your application makes it run faster. Launching another thread doesn’t cause Windows to give your application more processing cycles—it just divides those cycles over more threads. In fact, on a single-processor computer, multithreading makes your application run slower by adding additional thread management tasks to your application’s overhead.

    What multithreading does do is make your application more responsive. Where your application might otherwise have had to wait while some blocking task completes, with multithreading you can go and do something useful on another thread while waiting for the blocking task to complete. As a result, that second thread can let your application return a result earlier than it would have if the application had to wait for the blocking task to complete. On a single-core machine, it only made sense to use multithreading if a thread that was running for a blocked task didn’t need any processing cycles. If the thread wasn’t blocked, the two threads just ended up fighting for the limited number of processing cycles allocated to your application by Windows—and throwing away some of those cycles on activities like switching threads on and off the processor.

    Multi-core processors change that paradigm. In a multi-core environment you can get Windows to give your application more processing cycles by transferring a thread to one of the other cores on the computer. And you don’t need to have a blocked thread to take advantage of multithreading—all threads can execute on their own core.

    Parallel Extensions provides the programming constructs that allow you to tell the Microsoft .NET Framework which parts of your application can be run in parallel to get those benefits. In fact, Microsoft goes one step further: It claims that Parallel Extensions even changes the paradigm on single-core machines by reducing the overhead of managing multiple threads to the point where overhead simply doesn’t matter.

    Source of Information : Visual Studio Magazine August 2010


0 comments:

Leave a Reply