Multiprogramming and Multitasking in OS
Operating systems are very different from each other when compared internally. But there should be at least 2 common processes in every operating system which are as follows:
1. Multiprogramming
2. Multitasking(time-sharing)
We'll discuss both the operation here.
1. Multiprogramming: normally a user cannot keep the CPU or I/O device occupied all the time. If we don't have multiprogramming a user will keep the CPU or I/O device occupied all the time because when a single user wants to execute a particular task he will use the CPU until the task gets completed no other user can use the CPU or I/O device. But in multiprogramming, we are trying to increase the CPU utilization because the CPU is capable of executing multiple programs.
Diagram
Let's try to understand it with the help of a diagram
What are jobs?
It contains code and data
Here we have all the job pools which contain all the jobs that need to be executed or can also be said as jobs that entered the system.
MPS: these are the jobs that are loaded into the memory also we cannot load all the jobs into the memory because we don't have unlimited storage example 512 megabytes of RAM is not sufficient so every not able to load all of these into the memory so some of these jobs are loaded into the memory like in the above diagram we have loaded job1 job2 job3 job4 into the memory. The operating system helps in executing these jobs in case we don't have a multiprogramming now suppose job1 starts the execution and uses the CPU until it completely finishes the execution other jobs cannot use the CPU. Now it wants to use other resources for example I/O device the CPU is not used and it reminded idle without being used by others.
In multiprogramming, it goes to use any other resource the CPU is released from job 1 and the CPU instead of remaining idle it can be used by another job example it can go on to job 2 till job 1 finish the I/O device operation and want CPU back. Whenever a job does not want the CPU it can be utilized by another job so it is an efficient way of executing. In the end, it provides an environment in which various system resources like CPU memory and the peripheral device are utilized effectively but it is not used for user interaction with the computer.
2. Timesharing:
Here you can execute multiple jobs by switching among them. Switching happens so quickly that the user can interact with the program while it is running these were not there in multiprogramming. It requires an interactive computer system that provides direct communication between the user and the system. Also in the time-sharing operating system, it allows any user to share the computer simultaneously.
Diagram
In the above diagram, there is 4 user that is sharing the time-sharing computer system. Now suppose user 1 is using the time-sharing computer system and he wants to execute some job the job is being executed by the time-sharing computer system and the speed of CPU is very high and execution process is very fast after completion it shows the output the user. Now again user wants to execute some input to the CPU and it will be given at human speed. So the time gap itself is so big for the system because the system is very fast while the input is being given by user 1 at human speed in that gap CPU can be used by the ex: user2 for the execution of the job. It uses CPU scheduling and multiprogramming to allow each user a small portion of the time-sharing computer system. Also, all these users have at least one program waiting in the memory to be executed. When a program is loaded into the memory and the execution happens it is known as "process".
0 Comments