Multitasking vs. Multithreading

The earliest computers did one thing at a time. A lab computer might calculate detonation waves for one of the physicists. Next it would calculate mixing ratios for a chemist. All programs were run sequentially, one at a time; and each had full run of the computer. However two programs couldn't be run at once. This is called batch processing, and it's a very efficient way to get maximum usage out of a very expensive computer because almost all the computer's time is spent actually calculating jobs and not switching between one program and another. However batch processing can be very annoying when your differential equation integration program that would take all of two seconds of CPU time gets stuck in line behind the physics department's nuclear structure modeling project that's going run for the next three days.

Time sharing operating systems were invented to allow multiple people to use one then very expensive computer at the same time. On a time sharing system many people can run programs at the same time. The operating system is responsible for splitting the time among the different programs that are running. That way you can finish integrating your differential equation while the physics department's nuclear modeling program is still churning away. The physics department nuclear modeling program might take two weeks to run instead of three days, but everyone with the shorter programs is happy (at least until the physicists figured out how to hack the computer so that it only ran their program).

Once systems allowed different users to run programs at the same time it was a short step to letting the same user run multiple programs simultaneously. Each running program (generally caled a process) had its own memory space, its own set of variables, its own stack and heap, and so on. One process could spawn another process, but once that occurred the two processes behaved more or less independently. Mechanisms like remote procedure calls (RPC) were developed to allow processes to interact with each other, but such interaction was expensive and difficult. And this is where matters stopped for about twenty years.

However it's not just users that want to do different things at the same time. Many programs also need to do several things at once. A web browser, for instance, can print a file in the background while it downloads a page in one window and formats the page as it downloads. The ability of an individual program to do more than one thing at the same time is most efficiently implemented through threads.


Previous | Next | Top
Last Modified April 11, 1997
Copyright 1997 Elliotte Rusty Harold
elharo@sunsite.unc.edu