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 CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Difference between Preemptive Priority based and Non-preemptive Priority based CPU scheduling algorithms
- Difference between Preemptive and Non-preemptive CPU scheduling algorithms
- Preemptive and Non-Preemptive Scheduling
- Difference between Multiprogramming, multitasking, multithreading and multiprocessing
- Difference between Multiprogramming and Multitasking
- Process-based and Thread-based Multitasking
- Relation in FCFS and Preemptive Priority Scheduling Algorithm
- Program for Shortest Job First (or SJF) CPU Scheduling | Set 1 (Non- preemptive)
- Program for Shortest Job First (SJF) scheduling | Set 2 (Preemptive)
- Program for Preemptive Priority CPU Scheduling
- Implementation of Non-Preemptive Shortest Job First using Priority Queue
- First Come, First Serve – CPU Scheduling | (Non-preemptive)
- Shortest Job First (or SJF) CPU Scheduling Non-preemptive algorithm using Segment Tree
- Difference and Similarities between PHP and C
- Difference between Stop and Wait protocol and Sliding Window protocol
- Similarities and Difference between Java and C++
- Difference between Yaacomo and and XAP
- Difference between VoIP and and POTS
- Difference between ++*p, *p++ and *++p
- Difference Between DOS and Windows