What is the Difference Between Preemptive and Cooperative Multitasking

The main difference between preemptive and cooperative multitasking is that in preemptive multitasking, the operating system can initiate context switch from a running process to another process while in cooperative multitasking, the operating system does not initiate a content switch from a running process to another process.

Multitasking is the methodology of executing multiple tasks or processes concurrently over a period of time. Most modern operating systems support multitasking for maximum CPU utilization. Preemptive and cooperative multitasking are two types of multitasking.

Key Areas Covered

1. What is Preemptive Multitasking
-Definition, Functionality
2. What is Cooperative Multitasking
– Definition, Functionality
3. Difference Between Preemptive and Cooperative Multitasking
-Comparison of key differences

Key Terms

Cooperative Multitasking, Multitasking, Preemptive Multitasking

Difference Between Preemptive and Cooperative Multitasking

What is Preemptive 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.

Difference Between Preemptive and Cooperative Multitasking

Some operating systems give priorities to processes. In those situations, the higher priority process is executed first, before the lower priority processes. Higher priority processes get control as soon as they are initiated. Moreover, those processes might also get longer time slices to execute.

What is Cooperative Multitasking

Cooperative multitasking is another name for preemptive multitasking. In this 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.

In cooperative multitasking, we call the process scheduler of the operating system as the cooperative scheduler. It allows a simpler implementation of applications. Usually, cooperative multitasking is rarely used in large, complex systems. However, programming languages such as Python and JavaScript is used with a single threaded event loop on their runtime.

Difference Between Preemptive and Cooperative Multitasking

Definition

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. On the other hand, 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. Thus, this is the main difference between preemptive and cooperative multitasking. 

Control

Moreover, preemptive multitasking interrupts applications and gives control to other processes outside the application’s control, while in cooperative multitasking, process scheduler never interrupts a process unexpectedly. Hence, this is an important difference between preemptive and cooperative multitasking.

Examples

UNIX, Windows 95, Windows NT are some examples of operating systems with preemptive multitasking while Macintosh OS version 8.0-9.2.2 and Windows 3.x operating systems are based on cooperative multitasking.

Conclusion

In brief, preemptive and cooperative multitasking are two types of multitasking. The main difference between preemptive and cooperative multitasking is that in preemptive multitasking, the operating system can initiate context switch from a running process to another process, while in cooperative multitasking, the operating system does not initiate a context switch from a running process to another process.

Reference:

1.“What Is Preemptive Multitasking? – Definition from WhatIs.com.” WhatIs.com, Available here.
2.“Cooperative Multitasking.” Wikipedia, Wikimedia Foundation, 8 May 2019, Available here.
3.“Cooperative Multitasking.” What Is Cooperative Multitasking? Webopedia Definition, Available here.
4.“Preemption (Computing).” Wikipedia, Wikimedia Foundation, 8 May 2019, Available here.

Image Courtesy:

1.”Application-level multitasking” By Jeff Meisel – Meisel, J. Task Parallelism, Connexions Web site, Nov 28, 2007 (CC BY 2.0) via Commons Wikimedia

About the Author: Lithmee

Lithmee holds a Bachelor of Science degree in Computer Systems Engineering and is reading for her Master’s degree in Computer Science. She is passionate about sharing her knowldge in the areas of programming, data science, and computer systems.

Leave a Reply