How To

What is Multi-programming with preemption and no preemption?

multi programming

Multi-programming? What is it? How does it work? Multi-programming Operating System?

It is defined as when a program is treated by the CPU in parts instead of a whole at once and this helps an Operating System to make the user feel that more than one task is currently executed by the CPU. There are still two cases in that:

1. Processor with only one CPU (1 core CPU):

If this is the case, then the processor is actually mimicking the process of parallel execution of different programs but in reality only one process is being entertained by the CPU at one time and it is done in fraction of time, due to the fast context-switching of modern day processor it makes user feel that their processor/computer is capable of doing more than one task at a time.

2. Processor with more than one CPU (Multi-Core CPU):

In this case more are the cores in a CPU, more is the capability and overall performance of a system is increased. For example – if a computer has 4 core CPU then, in that case, it can easily handle a minimum of 4 tasks easily plus more with the help of context-switching.

Types of Multi-programming

1. Timesharing / with preemption / Multi-tasking:

  • In this, a process which is currently entertained by the CPU is being forced to switch/stop/pause in order to entertain another process and all this judged on different factors like the priority of a process and scheduling algorithms et cetera.
  • This process of switching from one process to another is known as context-switching.

Question: what is context-switching?

Answer: When a process needs to swapped with another process in order to give it CPU or I/O time

and it is done by saving the PCB/context of the process which is currently running.

operating systems context-switching

2. Without preemption

  • Once a process is given to CPU, it can not be taken back or cannot be context-switched until its work is completed.

Comment here