A species of multitasking in which the process currently utilizing the CPU must play nice and offer other processes a turn. As in socialism, if all the processes don't cooperate the results can be quite nasty. Both the Macintosh and Windows 3.x operating systems are based on cooperative multitasking, which is why they crash so often. More sophisticated OSes such as *nix, BeOS, Windows 9x (well, mostly), Windows NT, and OS/2 are based on preemptive multitasking.

Am I implying that Win95 is more sophisticated than MacOS? Well, sortof. I'm primarily talking about multitasking here, however.

Cooperative multitasking is your only option on machines that don't have the system timer necessary for the kernel to reassert control. Early processors (the 8086 and 80286, for example) couldn't do this, and so early operating systems (Windows 1.x, Windows 2.x early mac OS) used cooperative multitasking to allow multiple programs to appear to run simultaneously.

Cooperative multitasking works by providing running programs with a system call that returns control to the process scheduler. Programs are expected to 'cooperate' by yielding control to the kernel on a regular basis. If (because of incompetence, or maliciousness) they do not, the kernel has no way of re-asserting itself, and the system locks up. This was not a major problem for early operating systems - system memory was small, running more than two or three programs at a time was unusual, and most programs were written by large development teams, and tested extensively.

The introduction of more modern processors with a system timer, virtual machines, and (in some cases) memory protection led to the development of a new generation of operating systems. Using these new processors, it was possible to implement preemptive multitasking, a form of multitasking where the kernel can forcibly regain control from a malfunctioning process. All of the operating systems in this generation (windows 3.x, Mac OS < X1), however, valued compatibility with older processors and applications over system stability, and stuck with cooperative multitasking2.

Later versions of windows (9x, NT, XP) use preemptive multitasking exclusively. To maintain compatibility with windows 3.x programs, these programs share a virtual machine, inside which they cooperatively multitask. The virtual machine is multitasked preemptively, meaning that windows 3.x programs can affect the stability of other windows 3.x programs, but not the system, nor other DOS or win32 programs running on it. NT-based operating systems can optionally run windows 3.x programs in a separate virtual machine for greater stability, at a cost of greater memory usage.

No modern consumer OS uses cooperative multitasking, as it is just too easy for malicious code to bring down the system (a simple while(true); is all it takes). In the early days this wasn't a problem, but modern computers have much more memory, and can run far more programs simultaneously. Today's user has a much greater expectation of reliablility than a decade ago, and with widespread, affordable access to the internet, users are running programs from many more sources, some of which may be far more error prone. In addition, many operating systems now support multiple users, which would not be practical if one user could deny service to every other user with a one-line script.

Cooperative multitasking is still seen, however, in specialist systems - many PDAs use cooperative mutitasking, as it is computationally easier (and therefore better on the battery), and can be used on processors that do not support virtual machines and a system timer. Cooperative multitasking is also seen in some embedded systems, where all the software in the system custom-made, meaning there is no threat from malicious code.

1 - It seems unbelievable to me that MacOS never had preempive multitasking, but everywhere I've looked lists it as a new feature of os X. Somebody please tell me I'm mistaken...

2 - Windows 3, on a 386 used preemptive multitasking to properly multitask DOS applications - text-mode applications could be run in windows on the desktop, and text could be copied between them using the clipboard. On earlier windowses (and windows 3 on earlier processors) allowed only one DOS program to run at once, giving them full access to the display and processor, and using a dos keyboard handler to allow the user bring back windows again. With some programs this didn't work. Windows 3's "386 enhanced" mode was a key factor in its massive market share - it provided a real benefit to upgraders, even if they did not own any of the new windows applications. Even in "386 enhanced" mode, Windows applications were cooperatively multitasked, presumably to maintain consistent behaviour on all processors, and backwards compatibility with windows 2.x.

I cite:

Thankyou to Fisher for corrections.

Log in or register to write something here or to contact authors.