In: Computer Science
Using an original real-world example of your choice, explain how multiprogramming allocates and deallocates the processor illustrating carefully at least one interrupt and one context switch. Assume one processor shared by several jobs.
Before going to the example , let's look at about the topics and their defenitions.
Multiprogramming
Sharing the processor, when two or more programs reside in memory at the same time, is referred as multiprogramming. Multiprogramming assumes a single shared processor. Multiprogramming increases CPU utilization by organizing jobs so that the CPU always has one to execute.
Interrupts
Interrupts are signals sent to the CPU by external devices, normally I/O devices. They tell the CPU to stop its current activities and execute the appropriate part of the operating system.
Context Switching
Context Switching involves storing the context or state of a process so that it can be reloaded when required and execution can be resumed from the same point as earlier. This is a feature of a multitasking operating system and allows a single CPU to be shared by multiple processes.
Real-world example
Think about a class room,Let us consider the teacher as a processor, the class the teacher takes as a job and the time table as shedule.The teacher takes the class according to the time table. The attendant comes with a notice in the middle of the class and then the teacher stops the class and reads the notice.
In the above example according to time table the teacher is allocated to the class,(process allocated) when the time is ended or the bell rings, then the teacher wil stop the class.(i.e process deallocation is happened ).
When the attendant comes with a notice middle of the class (here the interrupt is happened) and then the teacher stops the class (processor stops the execution of job) and reads the notice(here context switching is happened) after that he resume the class. Also the teacher doing two jobs i.e multiprogramming is happened