Multiprogramming Operating System

By | September 5, 2021

Multiprogramming Operating System

  • Multiprogramming operating system allows multiple users to execute multiple programs using a single CPU concurrently i.e. at the same time.
  • In multiprogramming several processes are kept in the main memory and CPU execute all these processes concurrently. It means, the CPU immediately switches from one process to next that are ready to get executed.
  • Such a system is possible by having a mixture of CPU bound processes (i.e. the processes that mostly perform numerical calculation with little I/0 operations. Their CPU utilization is high) and I/O bound processes (i.e. the processes that perform very little computations and most of the time they perform I/O operations. Their CPU utilization is very low.)
  • In such an operating system when one process start performing I/O operations, the CPU is allocated to another user process in the main memory that is ready to use the CPU. Thus CPU never remains idle and is always kept busy executing some processes.
  • Multiprogramming does not mean that CPU executes the instructions from several programs at the same time. Rather, it means that there are number of programs available to CPU and that a portion of one is executed, then a segment of another and so on.
  • Although two or more users programs reside in the main memory simultaneously, the CPU is capable of executing only one instruction at a time. Hence, at any given time, only one of the programs has control of CPU and is executing instructions. Simultaneous execution of more than one program with single CPU is impossible.

Multiprogramming Operating System

  • In case of multiprogramming the various jobs residing in the main memory, can be in one of the following three stages:
  1.  Running: CPU is being used by the program
  2. Blocked: Performing I/O operation
  3.  Ready: Waiting for CPU to be assigned to it.
  • In our example, programs A, B and C are in blocked running and ready states respectively. Since job C is in ready state, as soon as execution of job B is completed or job B requires I/O operation, the CPU will start executing job C. In the meanwhile, if job A completes its output operation, it will be in the ready state waiting for CPU.

Three different states of jobs in multiprogramming operating system

  • The various examples of multiprogramming operating system are Windows NT, OS/2 and UNIX.

Requirements of Multiprogramming Operating System

The various features required by multiprogramming system are

1. Large Memory

For a multiprogramming to work satisfactorily, large main memory is required to accommodate a good number of user programs along with operating system.

2. Memory Protection

Computers designed for multiprogramming must provide some type of memory protection mechanism to prevent a program in one memory partition from changing information or instruction of a program in another memory partition. D

3. Job Status Preservation

  • In multiprogramming, when one running job is blocked for I/O operation, the CPU is taken away from that job and is given to some another job. Later on, when that job has finished its 1/O operation, it need to be resumed with its execution.
  • This requires preserving the status information of that job (when CPU was taken away from it) and restoring this information back (when CPU is given back to it)
  • For this an operating system uses Process Control Block (PCB) to save the status of each process (discussed in chapter 3).
  • Thus, in multiprogramming, before taking away the CPU from a running process, its status is preserved in its PCB and before the process resumes its execution (when CPU is given back to it), its status is restored back from its PCB.

4. Proper Job Mix

A proper mix of I/O-bound and CPU-bound processes is required so that the operations of CPU and I/O devices are balanced.

If all the loaded jobs need I/O at the same time, the CPU will be idle.

Thus, the main memory should contain some CPU-bound and some I/O-bound jobs so that at least one job is always ready to utilize the CPU.

5. CPU Scheduling

In a multiprogramming system, often there will be situations in which two or more jobs will be in the ready state, waiting for CPU to be allocated for execution.

In such a case, the operating system must decide to which process or job should CPU be allocated.

For this a CPU scheduler selects the processes and uses different CPU scheduling algorithms.

Advantages of Multiprogramming Operating System

  1. Increased throughput. Throughput is increased by utilizing the idle-time of CPU for running other programs that are already present in the main memory.
  2. Lowered Response Time. Response time is lowered by recognizing the priority of a job as it enters the system and by processing jobs on a priority basis.
  3. Ability to assign priorities to jobs. Most multiprogramming systems have schemes for setting priorities for rotating programs. They specify when the CPU will rotate to another program, and which program it will rotate to.

Disadvantages of Multiprogramming Operating System

  1. Multiprogramming is implemented through an operating system, which is a program that requires space in primary storage since it must be executed by the CPU. The operating system overhead is greater with multiprogramming that with batch processing.
  2. Jobs may have different sizes, therefore memory management is needed to accommodate them in memory.
  3. Many jobs may be ready to run on the CPU, which means that CPU scheduling is required.

One thought on “Multiprogramming Operating System

  1. Pingback: Virtual Memory - Advantages and disadvantages »

Leave a Reply

Your email address will not be published. Required fields are marked *