Multiprocessing
Don't confuse multiprocessing with multiprocess. Multiprocessing refers to the ability of an operating system to use multiple CPUs. Multiprocess is a programmatic model that uses multiple processes within an application. Confusing? Yes--but it's worth knowing the difference.
In many OSes, multiple processes appear to be executing concurrently at any given time. The Task Manager in Microsoft Windows NT/2000 or a process list in a Unix-based system shows a long list of processes that are running--all apparently at the same time.
From the viewpoint of the process, each one seems to have access to and control of all systems resources as if it were the only process running. But don't believe it for a minute. Most operating systems using a single CPU have only a single process executing at any given moment. The CPU scheduler--the kernel level process responsible for determining which process will take control of the CPU--rapidly changes the executing processes via scheduling algorithms to achieve the illusion of concurrent process execution. This is called multitasking.
Most OSes in use today are capable at least of multitasking (an example of a nonmultitasking OS is DOS). Only systems with multiple CPUs can support true concurrent processing, which is multiprocessing. And though a system can take advantage of multiple CPUs, concurrent processing will occur only if the operating system is able to take advantage of all the processing power available to it.
Multitasking is not a given, either. If the machine can cause an interrupt after a specified time, and the OS can take advantage of that interrupt, the OS will execute each program for a given length of time, regain control, execute another program for a given length of time and so on. Without this mechanism, the OS has no choice but to begin executing a program with the expectation, but not the certainty, that the program will eventually return control to the operating system.
So just how does the OS use multiprocessors to take advantage of the additional processing power? Several methods are used: MMP (massively parallel processing), SMP (symmetric multiprocessing) and ASMP (asymmetric multiprocessing). Each deals with multiple CPUs in a different way, which affects the level of additional performance you can expect from your multiprocessor machine.
MMP tightly couples multiple processors that use their own OSes and do not share memory within one machine. Because the processors do not have the overhead needed to maintain shared memory coherence and coordinate the execution of threads (or processes), an MPP system is scalable. However, if an MPP system fails, there is no built-in tolerance. Most systems have not used MPP primarily because of cost and the lack of a rich set of development tools. Most OSes use an SMP or ASMP architecture.
Symmetric Versus Asymmetric
In a symmetric multiprocessing system, each processor runs an identical copy of the operating system. Operating systems capable of using SMP include Digital Equipment Corp. Unix, IBM OS/2, Linux, Microsoft Windows NT and Sun Microsystems Solaris. SMP is an operating system's ability to schedule threads of code for execution on the first available CPU. An idle CPU always receives the next piece of code, resulting in a balanced distribution of code across the processors. Coherent memory is required by SMP, and the hardware must be able to react to redirect interrupt processing from one CPU to another.
In an asymmetric multiprocessing system, each CPU is assigned a specific task, with one master processor controlling the entire system. The relationship is that of master-slave, not unlike the relationships found between drive peripherals (hard drives, CD-ROM, floppy disk drives and so on). ASMP refers to the operating system's ability to schedule threads of code for execution on a specific CPU or, possibly, a group of CPUs. For example, CPU-1 might handle disk I/O, and CPU-2 may be responsible for video I/O. Instructions requiring disk reads and writes will be scheduled to execute on CPU-1, while output to video will be scheduled on CPU-2. Scheduling is easier in an ASMP system, which tends to be more scalable. Unfortunately, very few ASMP-capable operating systems are available. Almost all multiprocessor operating systems are SMP.
A Web server becomes much more efficient when running on a multiprocessor machine. In a single-processor environment, even though the Web server is responding to many requests, only one task is being serviced at any given time. In a multiprocessor machine, the Web server is able to service multiple requests at the same time because each task can be scheduled to run on separate CPUs, offering increased performance and efficiency.
Technology editor Lori MacVittie has been a software developer and a network administrator. Most recently, she was a member of the technical architecture team for a global transportation organization. Send your comments on this article to her at lmacvittie@nwc.com.