| • Science | • People | • Locations | • Timeline |
| Contents | ||
At any point in time only one task is said to be running, meaning that the CPU is actively executing instructions for that task. Multitasking solves the problem by scheduling which task may be the one running at any given time, and when another waiting task gets a turn. The act of reassigning a CPU from one task to another one is called a context switch. When context switches occur frequently enough the illusion of concurrency is achieved. Even on computers with more than one CPU (called multiprocessor machines), multitasking allows many more tasks to be run than there are CPUs.
Operating systems may adopt one of many different scheduling strategies, which generally fall into the following categories:
Nowadays, the term time-sharing is seldom used, being replaced by simply multitasking.
In the early days of computing, CPU time was expensive, and peripherals very slow. When the computer ran a program that needed access to a peripheral, the CPU would have to stop executing program instructions while the peripheral processed the data. This was deemed very inefficient.
The first efforts to create multiprogramming systems took place in the 1960s. Several different programs were loaded in the computer memory, and the first one began to run. When the first program reached an instruction waiting for a peripheral, the context of this program was stored away, and the second program in memory was given a chance to run. The process continued until all programs finished running.
Multiprogramming doesn't give any guarantee that a program will run in a timely manner. Indeed, the very first program may very well run for hours without needing access to a peripheral. As there were no users waiting at an interactive terminal, this was no problem : users handed a deck of punched cards to an operator, and came back a few hours later for printed results. Multiprogramming greatly reduced the waiting.
When computer usage evolved from batch mode to interactive mode, multiprogramming was no longer a suitable approach. Each user wanted to see his program running as if it was the only program in the computer. Time sharing had to be used.
Early multitasking systems consisted of suites of related applications that voluntarily ceded time to each other. This approach, which was eventually supported by many computer operating systems, is today known as cooperative multitasking. Although it is rarely used in larger systems, Microsoft Windows prior to Windows 95, and MacOS prior to OS X both used cooperative multitasking to enable the running of multiple applications simultaneously.
Cooperative multitasking has many shortcomings. For one, a cooperatively multitasked system must rely on each process to regularly give time to other processes on the system. A poorly designed program, or a "hung" process, can effectively bring the system to a halt. The design requirements of a cooperatively multitasked program can also be onerous for some purposes, and may result in irregular (or inefficient) use of system resources.