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.|
- Difference between Preemptive and Non-preemptive CPU scheduling algorithms
- Difference between Multiprogramming and Multitasking
- Difference between Multiprogramming, multitasking, multithreading and multiprocessing
- Difference between Preemptive Priority based and Non-preemptive Priority based CPU scheduling algorithms
- Preemptive and Non-Preemptive Scheduling
- First Come, First Serve – CPU Scheduling | (Non-preemptive)
- 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
- Process-based and Thread-based Multitasking
- Shortest Job First (or SJF) CPU Scheduling Non-preemptive algorithm using Segment Tree
- Difference between C and C#
- Difference between H.323 and SIP
- Difference between BFS and DFS
- Difference between IoT and M2M
- Difference Between SMO and SEO
- Difference between DFA and NFA
- Difference between GCC and G++
- Difference between CD-R and CD-RW