Difference between Preemptive and Cooperative Multitasking

Multitasking is the methodology of executing multiple tasks or processes concurrently over a period of time. Preemptive and cooperative multitasking are two types of multitasking.

In preemptive multitasking, the operating system can initiate a context switching from the running process to another process. In other words, the operating system allows stopping the execution of the currently running process and allocating the CPU to some other process. The OS uses some criteria to decide for how long a process should execute before allowing another process to use the operating system. The mechanism of taking control of the operating system from one process and giving it to another process is called preempting or preemption.

In cooperative multitasking, the operating system never initiates context switching from the running process to another process. A context switch occurs only when the processes voluntarily yield control periodically or when idle or logically blocked to allow multiple applications to execute simultaneously. Also, in this multitasking, all the processes cooperate for the scheduling scheme to work.

Let’s see the difference between preemptive multitasking and cooperative multitasking.

SR.NO. Preemptive Multitasking Cooperative Multitasking
1 Preemptive multitasking is a task used by the OS to decide for how long a task should be executed before allowing another task to use the OS. Cooperative multitasking is a type of computer multitasking in which the operating system never initiates a context switch from a running process to another process.
2 It interrupts applications and gives control to other processes outside the application’s control. In cooperative multitasking, process scheduler never interrupts a process unexpectedly.
3 The operating system can initiate context switch from a running process to another process. The operating system does not initiate a context switch from a running process to another process.
4 A malicious program initiates an infinite loop, it only hurts itself without affecting other programs or threads. A malicious program can bring the entire system to a halt by busy waiting or running an infinite loop and not giving up control.
5 Preemptive multitasking forces applications to share the CPU whether they want to or not. In cooperative multitasking, all programs must cooperate for it to work. If one program does not cooperate, it can hog the CPU.
6 UNIX, Windows 95, Windows NT operating systems are examples of preemptive multitasking . Macintosh OS version 8.0-9.2.2 and Windows 3.x operating systems are examples of cooperative multitasking.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.