So In this tech - blog, we will learn about exactly what is the meaning of the term "multiprogramming: multiprocessing: multitasking".
Multiprogramming :
A process executing in a computer system mainly requires two things i.e. CPU time and I/O time. The CPU time is the time taken by the CPU to execute a process and I/O time is the time taken by the process for I/O operations such as some file operation like read and write. Generally, our computer system wants to execute a number of processes at a time. But it is not possible. You can run only one process at a time in a processor. But this can result in some problems.
example:
Suppose we have a single processor system and we have 5 processes P1, P2, P3, P4, and P5 that are to be executed by the CPU. Since the CPU can execute only one process at a time, so it starts with the process P1 and after some time of execution of process P1, the process P1 requires some I/O operation. So, it leaves the CPU and starts performing that I/O operation. Now, the CPU will wait for the process P1 to come back for its execution, and the CPU will be in an idle state for that period of time. But at the same time, other processes i.e. P2, P3, P4, and P5 are waiting for their execution. Our CPU is in an idle state and this is a very expensive thing. So, why keep the CPU in the idle state? What we can do is, if the process P1 wants to perform some I/O operation then let the process P1 do the I/O job and at the same time, the CPU will be given to the process P2 and if the process P2 also requires some I/O operation, then the CPU will be given to process P3 and so on. This is called Context Switching. Once the I/O work is done by the processes then the CPU can resume the working of that process(i.e. the Process P1 and P2) and by doing so the CPU will never go into the idle state. This concept of effective CPU utilization is called Multiprogramming.
Main task is we should not let CPU sit like idle.
Thank you : )