Difference between cooperative and preemptive multitasking

2 min

What is multitasking

Multitasking is performing multiple tasks at a time. In a computer, multiple tasks/programs run at a time. For example, chrome browser, audio player, MS word program runs at the same time. The running of multiple programs/tasks at the same time is handled by the operating system.

If you have a single CPU (central processing unit) or single processor then the operating system gives a small time of processing to each task. Note that one task is run by the CPU at a time then the CPU shift to another task. The shifting of the CPU from one task to another task is so fast that it looks like all tasks are running at the same time. This is known as the slicing of time by the CPU. One time slice is given to each running process. The tasks are placed in a queue and all tasks are assigned a priority number. The task with high priority gets executed by the CPU first and other tasks have to wait. The switching of tasks by the CPU is also known as context switching.

Cooperative vs Preemptive Multitasking

What is cooperative multitasking

Cooperative multitasking is a type of multitasking in which a task can use the CPU as long as it wishes. That means all other programs have to wait till the first program finish executing or it is interrupted by any input/output trigger. Old operating systems use cooperative multitasking.

Example of cooperative multitasking

Cooperative multitasking was used in Mac OS version 8.0-9.2.2 and Windows 3.x

What is preemptive multitasking

In preemptive multitasking, each task is given a specific amount of time and each task is then interrupted by the CPU and CPU give time to other high priority tasks. In this type of multitasking, the tasks don’t decide by themselves that how much time they can execute but the processor has to decide context switching.

Example of preemptive multitasking

Preemptive multitasking is used by Windows 95, UNIX and Windows NT.

Cooperative vs preemptive multitasking

Cooperative MultitaskingPreemptive Multitasking
Each task has the ability to use CPU as long as it wishesEach task depends upon the CPU about how long it can be run by the CPU
Ideal for a single userIdeal for multiple users
CPU can be hanged if any program uses CPU for a longer timeIn most cases, the CPU cannot be hanged up
A malicious program can stop the working of the system if uses the CPU for a longer timeA malicious program cannot interfere with other programs and can be shut down by the CPU
Can use single coreCan use multiple cores
Examples are Windows 3.x and MAC OS 8.0-9.2.2Examples are Windows 95, UNIX, Windows NT

Like it? Share with your friends!

What's Your Reaction?

Junaid Rehman

I am a blogger and freelance web developer by profession. I love to blog and learn new things about programming and IT World.