Fundamentals of Microsoft .NET Programming: Multiprocessing

  • 10/15/2011
One particularly promising approach to improving computer performance is multiprocessing. This chapter from Start Here! Fundamentals of Microsoft .NET Programming describes multiprocessing and explains how you can take advantage of it to get the best performance possible.

In this chapter:

  • What multiprocessing is and how modern computers can provide it

  • The difference between multiprocessing and multitasking

  • What processes and threads are

  • How to design programs that can take advantage of multiprocessing

MOORE’S LAW, NAMED AFTER INTEL COFOUNDER Gordon E. Moore, says that the number of transistors that can be placed on a chip roughly doubles every two years, and that leads directly to an increase in computer speed. The law has held up remarkably well for more than 40 years and is predicted to continue to hold for at least a few more years, but chip manufacturers are starting to reach the physical limitations of what’s possible using current chip fabrication techniques. This might spell the end to large speed improvements for individual chips, but it doesn’t necessarily mean the end of performance gains for computers.

Other techniques, such as writing better code and leaner operating systems, can make a computer faster without changing its underlying hardware. One particularly promising approach to improving computer performance is multiprocessing.

This chapter describes multiprocessing and explains how you can take advantage of it to get the best performance possible.

Multitasking

Even the slowest computers are much faster than their human users. A typical computer spends practically all its time sitting around twiddling its electronic thumbs waiting for the user to do something. When the user presses a button or clicks the mouse, the computer springs into action, performs a task, and then goes back to waiting.

For example, the world record for fastest typing was set by Barbara Blackburn at 212 words per minute, or about 18 characters per second. Not even the world’s fastest typists can keep up with a computer that can execute millions of instructions per second.

To make better use of the computer’s blinding speed, modern operating systems multitask. In multitasking, the computer runs several tasks (known as processes) in turn. The operating system lets one process execute for a while so it can perform calculations, update its display on the screen, respond to user events such as button clicks, and so on. The operating system then pauses that process and lets another one take a turn. It continues rotating through the processes so they each get to execute.

So long as the operating system can switch the processes quickly enough, they appear to the user as if they are all executing simultaneously, although they are really just taking turns. This works well so long as the system doesn’t have too many intensive processes, but if some of the processes are performing really heavy-duty calculations, the computer may have trouble maintaining the illusion that it’s running simultaneous tasks.

This is where multiprocessing enters the picture. Multitasking fosters the illusion that the computer is performing several tasks at once. In multiprocessing, the computer really is doing several things simultaneously.