Multi-Programming Vs. Multitasking
In this lecture, we will see multi-programming vs. multitasking in detail with its comparisons. Let’s start with multi-programming,
What is Multi-Programming?
Multi-programming is an early form of parallel processing in which several programs are run simultaneously on a single processor (uni-processor).
It is a Non-preemptive where the CPU executes the entire process before executing the next waiting process. But the condition is that if a running process request for any I/O or external interrupt occurs during that process execution. Then, the CPU will block that running process and move to that particular Let’s
Let’s explain with Example
suppose there are three Processes: P1, P2, and P3. And their time of execution is 10, 15, and 05, respectively. Then, P1 completely executes from time 0-10. Then P2 executes from time 10-25. In the last, P3 will execute from a 25-30 time period. Keep in mind that there is no interruption occurs during the execution of these processes. If it happens, then the CPU moves to that particular interrupt. Explain in the diagram given below,
Advantages of multi-programming systems
- CPU Utilization is maximum because the CPU never becomes idle due to Less context Switching.
- Memory and Resources are managed easily because of non-preemptive.
- It supports multiple users
- Short-time jobs are executed earlier than long-time jobs.
Disadvantages of multi-programming systems
- Less the Response time.
- Due to non-preemptive, long-time jobs have to wait long
- Handling all processes is sometimes difficult.
What is Multitasking?
Multitasking works through preemptive mode, where every process executes for some period of time. This time is also called the Quantum period.
The condition will be the same as for multi-programming if a process request for I/O or any external interrupt occurs during that process execution. Then, the CPU will block that running process and move to that interrupt Handler.
In the modern OS, we are able to play music and write in Microsoft Word, Google Chrome, and many more processes simultaneously, which are achieved by means of multitasking.
Let’s explain with Example.
Suppose there are three Processes: P1, P2, and P3. Their time for execution is 10, 15, and 05, respectively. The quantum period of all processes is 05. Then, P1 will execute from time 0-5. P2 will execute from time 5-10. P3 will execute Form 10-15 during the time period. Still, only P3 completes its execution. No P1 will execute from time 15-20 for its remaining execution time. In the same way, P2 executes from time 20-30. Keep in mind that there is no interruption occurs during the execution of these processes. If it happens, then the CPU moves to that particular interrupt.
Advantages of multitasking:
- Highly Response Time
- Saves time, money
Disadvantages of multitasking:
- CPU sits idle due to high context switching
Types of Multitasking
- Process-based multitasking
- Thread based multitasking
Multi-programming vs. Multitasking
Now look at the comparison, multi-programming vs. multitasking
|It was early used
|It is used nowadays in Laptops and PC
|Less Context Switching due to non-preemptive mode
|Highly Context Switching due to preemptive mode
|The main target is CPU utilization because of less context switching.
|Primary target: Responsive because of Highly Context Switching.
Note: Multi-CPU’samming, multitasking, and multi-threading are eCPU’sed on a single CPU or multiple CPUs. But Multiprocessing only executes on various CPUs.