Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Multi-Programming Operating System | Easy Explaination using

Animation

Multi-Programming Operating System


in a multiprogramming system two or more user programs can be in memory and are
executed one after another

Why Multi-Programming?
Multi-programming operating system as we have seen in previous video early operating
systems would execute one program at a time one program was loaded into the RAM that is
main memory and the CPU would execute it until the program is executed completely no
other program was executed the problem behind this was when a program required some
input/output operation or some other operation or it requires to access some file it would
move out of the CPU for that particular operation so when that would happen CPU remained
idle and CPU utilization was very low.

How does it Work?


In multi programming operating system multiple programs or processes which are to be
executed are loaded into the main memory operating system will then assign the process p1
to the cpu the cpu will start execution of p1 cpu will complete the execution of p1 completely
and then go to process p2 unless p1 is interrupted by external factor or it goes for input/output
operation if p1 is interrupted then operating system assigns next job say p2 to the CPU the
CPU then starts execution on p2 whenever the p1 completes its operation and comes back for
execution CPU is allocated for that process and then p1 is executed and then other processes
are executed one by one in same fashion.

Real life Example


let's say you are a school teacher and you need to take oral exam of students as per their role
numbers which contains ten questions you start with first student ask all ten questions and
then move on to the second one you ask five questions and student asks you for a washroom
break you give him permission and he leaves now time is important for you and you can't
waste any time as you need to complete the exams for whole class so you move on to the
third student and start his or her ten questions when the previous student returns you
complete his remaining five questions then move on to the fourth and so on same is done in
multi-programming operating system CPU does not remain idle it will be in working state
every time until there is no process for execution.
Proper Example
Consider there are three processes first operating system will allocate CPU

For process one CPU will start the execution let's say p1 does not require to go out
for any operation so CPU will execute p1 completely as p1 is executed it will be
removed from the main memory

now operating system will allocate CPU for process 2 CPU will start its execution let's say p2
requires some input/output operation the CPU will stop the execution for p2 p2 will go out of
CPU for the operation

now the CPU will not wait for p2 to finish its operation operating system will allocate process
3 to the CPU and CPU will start the execution on p3 and will execute p3 until p2 comes back
once p2 comes back it will stop execution of p3 and start executing p2 and after executing p2
completely it will go for p3 and execute p3 completely

this way CPU never remains idle until it completes all processes and this is how multi
programming works and overcomes the problem of low CPU utilization

Advantages

 CPU UTILIZATION IS MAXIMUM


 SHORT TIME JOBS GET EXECUTED FASTER
 RESOURCES ARE USED EFFICIENTLY
 RESPONSE TIME IS SHORTER

Dis-advantages

 DIFFICULT TO PROGRAM A SYSTEM BECAUSE OF COMPLICATED


SCHEDULE HANDLING
 DUE TO HIGH LOAD OF TASKS, LONG TIME JOBS HAVE TO WAIT LONG

You might also like