Since we know that operating systems vary greatly in their functionality. Some operating systems are designed to provide ease of usability whereas some are designed to provide efficiency and many more. But, one aspect that is quite common for all operating systems is their ability to switch among and run multiple programs at a time. This ability is also known as multiprogramming.
If a CPU runs a single program at a time, it will be kept idle if it wants input from a user. For example, the user needs to type START to start the execution of a program, until the user types the command the CPU will sit idle for a lot of time depending upon the typing speed of the user. This will reduce CPU utilization to a large extent.
What is multiprogramming in operating system?
So, multiprogramming allows the CPU to work on more than one task by loading multiple tasks into the memory. But, the primary memory is also limited. So, there is a pool of processes which is called a job pool in the secondary memory, from which some of the processes are loaded to the main memory and the operating system executes the processes from these. Thus, the set of processes in the main memory is a subset of the processes in the hard disk memory pool.
Also check: segmentation in os
This idea is quite similar to the real-life scenario where a lawyer takes multiple cases and if any case is waiting to go to trial, then the lawyer works on any other case. He will never sit idle which will increase his load and thus, working efficiency.
One more extension of this multiprogramming is the time-sharing system. In this, the switching among the multiple processes is made on a timely basis. Each process is given a certain amount of time to execute. If it fully executes within the time then it is fine, otherwise, the process is paused and the operating system starts working on the next process only after a certain time, the turn of the paused process comes and it resumes from where it has stopped. This pausing of a process in between is called pre-emption.
Due to this time-sharing, the CPU also be shared among multiple users. The resources are shared between multiple users and multiple users can work on a system simultaneously. But, the sharing of CPU among the users is so fast that every user thinks that the CPU is dedicated to his tasks only. Each user has his part loaded into memory. The task when loaded into memory and ready for execution is called a process.
If several processes are loaded into the main memory, there is not enough room available to execute multiple processes simultaneously, then the CPU chooses among the processes loaded into the memory. The CPU making this decision is referred to as Job Scheduling.
So, in this article, we learned about multiprogramming and some essential terms related to multiprogramming, which are used commonly while studying operating systems.
You may also like to read: Uniprogramming and Multiprogramming with their differences