Difference Between Multiprogramming and Multitasking

In every computer system, the major part or we can say the heart of the system is its operating systems. The operating system not only works with the memory (primary and secondary) but it also helps in managing user’s direct interaction with the computer’s application. The operating system alone can provide us with a complete virtual computer so we can say that without operating system, computer is nothing but a box consisting of a variety of complex infrastructure which can do absolutely nothing.

Along with the basic functionalities an operating system helps in performing i.e. basic file handling, connecting to an external device or either connecting to a Bluetooth devices and sending or receiving files in the system, the operating system also do some major functionalities which we (as a layman) never bother to ponder upon.

The higher purposes served by an operating system are the major topic of discussion in the article, i.e. multiprogramming and multitasking. The operating system also works with multiprocessing and multithreading as well which we will discuss further some time later. Lets’ get back to our major topic of discussion i.e. multiprogramming and multitasking. These features of an operating system make sure that different programs or tasks can run simultaneously without interfering with each other. The term used for this multiple execution is parallel processing. However, the operating system not only supports multiprogramming and multitasking, but it also serves timesharing concept in multiprogramming.

Basics of  Multiprogramming:

In operating systems, multiprogramming is a word named after parallel processing. As the name refers it is used to process multiple programs simultaneously using a single processor i.e. CPU (Central Processing Unit). As is obvious every computer system has only one processor that is CPU so the question here is how we can provide different processor to every processes/program running concurrently in parallel processing? This is done by CPU virtualization, in CPU virtualization we give user a fake image that they are using multiple processors each for each processes or program, however, in real time, a single processor process a part of one program for a small amount of time and then leaves it and then moves towards the next program and implements a small portion of that program.

However, again a question arises here how we tell the CPU that stop executing program 1 and moves toward program 2 now? The solution to this problem lies in interrupts. If we manage to generate interrupts after a specific period of time, then we can achieve the phenomenon of multiprogramming on time basis. The operating system automatically generates an interrupt after a defined period of time and after the occurrence of the interrupt and the CPU leaves the program it is currently running, also the CPU will not be allocated again to the processes it left at the time of the interrupt occurrence, and hence we achieve the switching of CPU between two different programs.

Using this mechanism, we can take bake control from the CPU certainly because no matter what the program is running, we will get back the control of the CPU one way or the other. But if we are not using this mechanism, we are not certain if we will get back the control of the CPU from the program ever or not. Because only the completion of the program or exception in it will cause it to give back the control to the CPU and what if the program does not have any exception or it contains an infinite loop in it. This case will cause a serious problem though.

In layman language, by multiprogramming we mean that multiple users can work on single processor at one time. The figure below shows multiprogramming in an elaborated form. Difference Between Multiprogramming and Multitasking

Figure 1: Multiprogramming

Need of multiprogramming

Again, the question that arises here is why one will ever need to make their life this much complex by introducing multiprogramming, why don’t we just let the CPU finish one job first and then move towards the other? The answer to this lies in the underutilization of CPU i.e. when we go for the scenario in which we give processes to CPU one buy one then the CPU may not be utilized fully.

When the process given to CPU encounters an external interrupt or some input output stuff, what will CPU do at that time? will it just sit there and wait for the process to settle down it matters and come back for processing on its will, this is not how Central Processing Units act like. To use the CPU fully we let the programs to wait for the CPU while the CPU is done with other programs it is currently running and after a few nanoseconds hands the CPU over to some other program to fulfil the demand of maximum CPU utilization and multiprogramming.

Lets’ now talk about multitasking.

Basics of Multitasking

As far as the difference between multiprogramming and multitasking is concerned, the major difference is that in multiprogramming we allow multiple users to work of different programs using same computer however in case of multitasking we allow a single user to perform various tasks on a single computer having single CPU. For instance, if you have opened a browser on your computer and you also want to open word along with that and the operating system is allowing you to do so than (hurray) your operating system supports multitasking.

Now a days almost every operating system supports multitasking and the operating system that supports multitasking are Windows, MacOS, Linux etc. to name a few. Not only this along with multitasking the operating system also keeps a track of where the user is in each of these tasks whenever the user switches between these tasks. The figure below shows a general example of multitaskingDifference Between Multiprogramming and Multitasking

Figure 2: Multitasking

While talking about multitasking we can also say that implementation of multiple tasks (i.e. process, thread and program) on one time is referred as multitasking which also true in its essence.

Multitasking is also sometimes called as the extension of multiprogramming, however talking about the base comparison, multiprogramming is solely related to switching the complete program in main memory b fetching it from secondary storage devices (i.e. context switch) by changing the code, stack, heap and data section of the processes, however multitasking says that along with this context switch one should also consider the time sharing property of the CPU, and utilize it for good.

For instance, when we talk about time sharing, we mean that out of every processes which needs to be run, we assign every processes a quantum of time or which it will do its execution and after that it will move the CPU to the next process. Now let’s have a look on the basic comparison between both of them.

Comparison Chart 

DefinitionMultiple users can work on different programs using same CPUOne user can work on multiple programs using same CPU
CPU sharingCPU sharing based on processes i.e. process sharing of CPUTime sharing of CPU
OccurrenceOccurs when a single process completes its executionOccurs when a single time slice of CPU ends i.e. timed interrupt occurs
ComplexitySimple for executionVery complex compared to multiprogramming
PurposeMaximum CPU utilizationMinimum response time of the CPU

Leave a Comment