Multi-Programming Vs. Multitasking
In this lecture, we will see multi-programming vs. multitasking in details 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 at the same time on a single processor (uni-processor).
It is a Non preemptive where CPU execute the entire process before to execute the next waiting process. But the condition is that, if running process request for any I/O or external interrupt is occur during that process execution. Then CPU will block that running process and move to that particular interrupt.
Let’s explain with Example
let suppose, there are three Processes P1, P2, and P3. And their time of execution is 10, 15 and 05 respectively. Then P1 completely execute from time 0-10. Then P2 execute from time 10-25. And in the last P3 will execute form 25-30 time period. Keep in mind, there is no interrupt occur while execution of these processes. If it happened then CPU move to that particular interrupt. Explain in diagram given below,
Advantages of multi-programming systems
- CPU Utilization is maximum because CPU never become idle due to Less context Switching.
- Memory and Resources are managed easily because of non-preemptive.
- It support multiply users
- Short time jobs are executed early than long time jobs.
Disadvantages of multi-programming systems
- Less the Response time.
- Due to non-preemptive, long time jobs have to wait long
- To handle 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 Quantum period.
Condition will be same as for multi-programming that, if process request for I/O, or any external interrupt is occur during that process execution. Then CPU will block that running process and move to that interrupt Handler.
In the modern OS, we are able to play music, writing in Microsoft Word, Google Chrome and many more process simultaneously. This is achieved by means of multi-tasking.
Let’s explain with Example.
If there are three Processes P1, P2, and P3. Their time for execution is 10, 15 and 05 respectively. And Quantum period of all processes is 05. Then P1 will execute from time 0-5. P2 will execute from time 5-10.And P3 will execute form 10-15 time period. Still only P3 complete its execution. No P1 will execute from time 15-20 for its remaining execution time. In the same way P2 execute form time 20-30. Keep in mind, there is no interrupt occur while execution of these processes. If it happened then CPU move to that particular interrupt.
Advantages of multitasking:
- Highly Response Time
- Saves time ,Saves money
Disadvantages of multitasking:
- CPU sit idle due to Highly Context switching
Types of Multitasking
- Process based multi-tasking
- Thread based multi-tasking
Multi-programming vs. Multitasking
Now look at the comparison, multi-programming vs. multitasking
|It was early used||It used now a days in Laptops and PC|
|Less Context Switching due to non-preemptive mode||Highly Context Switching due to preemptive mode|
|Non Responsive||Highly Responsive|
|No time sharing||Time sharing|
|Main target: CPU utilization because of less Context Switching.||Main target: Responsive because of Highly Context Switching.|
Note: Multi programming, multitasking, multi-threading are execute on single CPU or multiple CPU’s. But Multiprocessing only execute on multiple CPU’s.