Partitions – Memory Management

By | October 23, 2021

Partitioning is the method of dividing the main memory into certain fixed size or variable size partitions. There are various schemes that are used for partitioning. These are discussed in the subsequent sections:

1. Single partitions allocation (Monoprogramming)

  • This method of partitioning is also known as single user contiguous allocation or single process system.
  • It is simplest memory management scheme in which only one process can run at a time i.e. only one process is present in the memory at a time and this process is allowed to use the entire user space of memory.
  • In this system, the memory is divided into two contiguous areas. One of them is permanently allocated to the operating system and the other is occupied by the single user process.
  • The process to be executed is loaded into the free space area of memory and a part of the memory space will be unused.

Single Partition Allocation

  • The operating system may be placed in either low memory or high memory. The choice of a particular end of the memory i.e. high or low, depends on the location of interrupt vector table. In order to protect this vital system data, the interrupt vector table is usually made a part of the operating system.
  • Easy MS-DOS systems operated in this ways and nowadays it is used in simple systems such as game computers.

Protection in Single Partition Allocation

  • It is important that the operating system must be protected from destruction by the user program i.e. the user program does not interfere with memory occupied by OS.
  • Such a protection is provided by using a single register called boundary register or fence register or base register.
  • This register marks a boundary between the operating system and user process area.
  • If the operating system occupies the low memory then this boundary register is set to the highest address occupied by operating system code.

Single register contains the highest address occupied by OS

  • Each memory address generated by user program is compared with the value in this register. If the user tries to enter the operating system, the instruction is intercepted and the job terminates with an appropriate error message.

Memory Protection in Single Partition Allocation

Advantages of single partition allocation

  1. The memory allocation scheme is simple, straight forward and free from complexities of multiprogramming.
  2. It requires less hardware support.
  3. It does not require great expertise to understand or use such system.

Disadvantages of signal partition allocation

  1. It does not support multiprogramming as only one user process can reside in the main memory at a time.
  2. It results in poor utilization of processor. If a single process is busy in I/O operation, processor cycles are wasted and no other process is available for CPU.
  3. Memory is underutilized as the portion of memory (not occupied by OS and single active process) goes waste.
  4. There is a lack of flexibility as user’s job is limited to the size of available main memory.

2. Multiple Fixed Partitions Allocation

  • This memory allocation scheme supports multiprogramming.

Multiple Fixed Partition Allocation

  • In multiple fixed partition scheme, multiple partitions of fixed size are created to allow multiple user processes to be present in memory at the same time. Each partition may contain one process. However a process may occupy more than one partition depending upon its requirement.
  • Thus, OS occupies some fixed portion of main memory and the rest of main memory is available for use by multiple processes. In multiple fixed partition, the partitions can be of equal size or unequal size.
  • In case of equal-size partitions, any process whose size is less than of equal to the partition size can be loaded into any available partition. If all the partition are full and no resident process is in ready or running state, the operating system swaps out one of the processes so as to make room for a new process.

Equal size and Unequal Size partition

  • In case of unequal size partitions, the process is loaded into a partition whose capacity /size is greater than or equal to the memory requirement of process. Fixed partition method was successfully used by IBM’s operating system – OS/360 MFT (Multiprogramming with Fixed number of Tasks).

Method of Operation of multiple fixed partition

  • Once the partitions are defined operating system keeps the track of all the partitions to check whether they are free or in use. This helps in allocation purposes.
  • For this, OS by maintains a table called partition description table (PDT).
  • PDT contains current status information (free or used) along with the other attributes of partition.
  • In PDT, each partition is described by its starting address (base), size and status.
  • In fixed partitioning, only the status field of each entry changes in the course of system operation, indicating whether the corresponding partition is free or allocated.
  • All other fields such as base and size are static and are defined at the time of creation of partition.
  • Initially, all memory (i.e. all partitions) are free and are available for user processes and is considered as one large block of memory called a hole.
  • When new process arrives and needs memory, operating system searches a hole large enough for this process consulting the entries of PDT.

Multiple Fixed Partitions and PDT

  • If the search is successful, the status field of the selected partition is marked ALLOCATED and the process image is loaded into the corresponding partition.
  • Whenever the process terminates or needs to be swapped out, the information is obtained from PDT for the corresponding partition and its status is changed to FREE.

Protection in multiple fixed partitions

  • When multiple user processes and OS reside in the main memory at the same time, it is important to ensure that the various user processes should not interfere with each other.
  • The processes should not also interfere with operating system. Thus, not only the OS needs to be protected from user processes the various processes also need to be protected from each other.
  • This can be done by using a relocation register with a limit register. The relocation register contains the starting address of the process (physical address).
  • The content of relocation register is added to the address generated by the process (logical address).
  • The limit register contains the range of logical addresses. Thus, it marks the end of partition. It contains either the size of partition or the last address in the partition.
  • When CPU scheduler selects a process for execution, the dispatcher loads the relocation and limit registers with the correct values as a part of context switch.
  • The address generated by CPU is checked against these registers so that the running process does not enter the range of OS or any other user process.

Memory protection in multiple fixed partition scheme

Advantages of Multiple fixed partition system

  • It is simple scheme and easy to implement.
  • It generates little OS overhead.

Disadvantages of multiple fixed partition system

  • It suffers from internal fragmentation. Processes that are smaller than the size of the partition do not fill partitions completely and create holes. As a result portion of partition space is wasted.
  • The number of partitions are specified at the time of system generation. This limits the number of active processes in the system.
  • The fixed partition sizes can prevent a process being run due to the unavailability of a partition of sufficient size.

3. Multiple Variable Partitions Allocation

  • Variable partitioning scheme is also know as dynamic partitioning.
  • In variable size partition memory is partitioned on run time depending upon the requirement of the programs running on a computer.
  • In dynamic partitioning, memory is not divided into fixed set of partitions i.e. partitions are of variable length and variable number. No fixed boundaries are observed.
  • The amount of space allocated to a process is the exact amount of space it requires. Thus it does not suffers from internal fragmentation.
  • The initial partition assignment in variable partitioning is shown in figure. This example uses main memory of 1MB. Initially, main memory is empty except for the operating system (100 k). The first four processes A, B, C and D are loaded in, starting where the OS ends, and occupy just enough space for each process.
  • As a result, a hole is left at the end of the memory & this hole is too small for fifth process. (Process E that requires 150K of memory).

Effect of Dynamic Partitions

At some point, none of the processes in the memory is ready. The operating system therefore swaps out process B which provides sufficient room to load a new process E. As process E is smaller than process B, another small hole is created.

Methods of Operation in Multiple Variable Partition Allocation

  • In variable partition, a set of holes, of various sizes, is scattered throughout memory at any given time.
  • When a process arrives and needs memory, the OS searches for a hole that is large enough for this process.
  • If the hole is too large, it is divided into two parts. One part is allocated to the arriving process and the other is returned to the set of holes.
  • For each partition allocated, the information like base address of partition, size and its status (ALLOCATED) is added to partition description table (PDT).
  • When a process terminates, it releases its block of memory. This block of memory is placed back in the set of holes.
  • If the new hole is adjacent to other holes, these adjacent holes are merged to form one larger hole.

Advantage of multiple variable partition system

  1. It is simple method because the entire process is allocated contiguous memory. This makes addressing (with a process) very simple.
  2. It does not suffer from internal fragmentation.

Disadvantages of multiple variable partition scheme

  1. There is no possibility of sharing data and instructions among the processes; (loaded into entirely different portions of the memory).
  2. Degree of multiprogramming is dependent on the availability of a partition that can accommodate a process wholly. This reduces the number of ready processes in the memory.