Multi Programming

Thanoshan MV
2 min readJul 22, 2020

--

Photo by Pietra Schwarzler on Unsplash

If a computer runs multiple programs at a time then it is known as multi programming. For example, running Google Chrome and Windows Media Player simultaneously.

This concept is for single CPU (single processor).

Multi programming system executes a process at a time on a single processor concurrently.

Operating System (OS) mainly contributes for multi programming.

Processes are executed by CPU. Processes (jobs) wait at job pool for CPU (processor) allocation in order to execute. CPU selects a process from job pool and executes it.

Non Multi Programming System

In a non multi programming system, CPU executes a process until that process requires for an I/O task or an external factor interruption.

Let’s say a process that is currently executed by CPU requires an I/O, it will leave the CPU for I/O. Now, CPU does not have any process for execution. CPU becomes idle.

Although job pool contains processes that are ready to be executed and waiting for CPU allocation, the CPU will not select any of them.

CPU will wait until that process which went for I/O comes back. When it comes back to CPU (after its I/O task), the CPU will execute it.

The problem is, we are wasting CPU time. Multi programming resolves this issue.

Multi Programming System

The main concept of multi programming is to maximize CPU time.

In a multi programming system, if a process leaves CPU for I/O, the Operating System (OS) interrupts that process and assigns a new process to CPU for execution.

When CPU switches to another process, context switch stores the previous process state and loads the new process state. Context switch shares single CPU between multiple processes. It is an essential feature in multi programming and multi tasking.

If that previous process is finished with I/O task and requires for CPU execution, it goes to job pool. Later at some point of time CPU will execute it.

In this way, we never wasted CPU time (no waiting for I/O tasks to be completed).

CPU executes a process at a time. It executes a process of a program then it executes a process of another program and so on.

Advantages of Multi Programming

Maximize CPU utilization.

Disadvantages of Multi Programming

Some processes may execute for long period of time. Other processes may not have CPU time to be executed. So, user may experience less user interaction of programs.

--

--

Thanoshan MV
Thanoshan MV

Written by Thanoshan MV

Hi! I'm a Software Engineer with a passion for research in AI, software engineering, and open-source development. Web - https://thanoshanmv.github.io/

No responses yet