Skip to content

Memory Management

  • Memory devices are digital system that store data either temporarily or for a long term.
  • Memories are made up of registers.
  • Each register in the memory is one storage location/ memory location.
  • Memory locations are identified using Address.
  • The total number of bits a memory can store is its capacity.
  • Each register is made up of a storage element in which one bit of data is stored.
  • The data in a memory are stored and retrieved by the process called writing and reading respectively.

Following are some important memory units :

  1. Bit (Binary Units): bit is a logical representation of the electric state. It can be 1 or 0.
  2. Nibble: it means the group of 4 bits.
  3. Byte: a byte is a group of 8 bits.
  4. Word: it is a fixed number of bits, it is different from computer to computer, but the same for each device. Compute store information in the form of words.

Following are conversations of units:

  1. Kilobyte (kb): 1kb = 1024 byte
  2. Megabyte (mb): 1mb = 1024 kb
  3. Gigabyte (gb): 1gb = 1024 mb
  4. Terabyte (tb): 1tb = 1024 gb
  5. Petabyte (pb): 1pb = 1024 tb

Four common memory management techniques in operating system

  1. Single contiguous allocation

  2. Simplest allocation method used by MS-DOS. All memory (except some reserved for OS) is available to a process.

  3. Partitioned allocation

  4. Memory is divided into different blocks or partitions. Each process is allocated according to the requirement.

  5. Paged memory management

  6. Memory is divided into fixed-sized units called page frames, used in a virtual memory environment.

  7. Segmented memory management

  8. Memory is divided into different segments (a segment is a logical grouping of the process’ data or code).In this management, allocated memory doesn’t have to be contiguous.

Partition Allocation

  • In Partition Allocation, when there is more than one partition freely available to accommodate a process’s request, a partition must be selected.

  • To choose a particular partition, a partition allocation method is needed.

  • A partition allocation method is considered better if it avoids internal fragmentation.

  • When it is time to load a process into the main memory and if there is more than one free block of memory of sufficient size then the OS decides which free block to allocate.

  • There are different Placement Algorithm:

  • First Fit

    • In the first fit, the partition is allocated which is the first sufficient block from the top of Main Memory.
    • It scans memory from the beginning and chooses the first available block that is large enough.
    • Thus it allocates the first hole that is large enough.
  • Best Fit

    • Allocate the process to the partition which is the first smallest sufficient partition among the free available partition.
    • It searches the entire list of holes to find the smallest hole whose size is greater than or equal to the size of the process.
  • Worst Fit

    • Allocate the process to the partition which is the largest sufficient among the freely available partitions available in the main memory.
    • It is opposite to the best-fit algorithm.
    • It searches the entire list of holes to find the largest hole and allocate it to process.
  • Next Fit

    • Next fit is similar to the first fit but it will search for the first sufficient partition from the last allocation point.

Contiguous Memory Management

  • There are two Memory Management Techniques: Contiguous, and Non-Contiguous.
  • In Contiguous Technique, executing process must be loaded entirely in the main memory.
  • Contiguous Technique can be divided into:
  • Fixed (or static) partitioning
  • Variable (or dynamic) partitioning

Fixed / Static Partitioning

  • In this technique, the main memory is divided into partitions of equal or different sizes.
  • The operating system always resides in the first partition while the other partitions can be used to store user processes.
  • The memory is assigned to the processes in contiguous way.
  • In fixed partitioning, the partitions cannot overlap and a process must be contiguously present in a partition for the execution.
  • Advantages of Fixed Partitioning:

  • Easy to implement:

    • Algorithms needed to implement Fixed Partitioning are easy to implement.
    • It simply requires putting a process into a certain partition without focusing on the emergence of Internal and External Fragmentation.
  • Little OS overhead:

    • Processing of Fixed Partitioning requires lesser excess and indirect computational power.
  • Disadvantages of Fixed Partitioning

  • Internal Fragmentation:

    • Main memory use is inefficient. Any program, no matter how small, occupies an entire partition. This can cause internal fragmentation.
  • External Fragmentation:

    • The total unused space (as stated above) of various partitions cannot be used to load the processes even though there is space available but not in the contiguous form (as spanning is not allowed).
  • Limit process size:

    • Process of size greater than the size of the partition in Main Memory cannot be accommodated.
    • The partition size cannot be varied according to the size of the incoming process size. Hence, the process size of 32MB in the above-stated example is invalid.
  • Limitation on Degree of Multiprogramming:

    • Partitions in Main Memory are made before execution or during system configure.
    • Main Memory is divided into a fixed number of partitions.
    • Suppose if there are n1 partitions in RAM and n2 are the number of processes, then n2 <= n1 condition must be fulfilled.
    • Number of processes greater than the number of partitions in RAM is invalid in Fixed Partitioning.

Variable / Dynamic Partitioning

  • Dynamic partitioning tries to overcome the problems caused by fixed partitioning.
  • In this technique, the partition size is not declared initially.
  • It is declared at the time of process loading.
  • The first partition is reserved for the operating system.
  • The remaining space is divided into parts.
  • The size of each partition will be equal to the size of the process.
  • The partition size varies according to the need of the process so that the internal fragmentation can be avoided.
  • Advantages of Variable Partitioning –

  • No Internal Fragmentation:

    • In variable Partitioning, space in main memory is allocated strictly according to the need of process, hence there is no case of internal fragmentation.
    • There will be no unused space left in the partition.
  • No restriction on Degree of Multiprogramming:
    • More number of processes can be accommodated due to absence of internal fragmentation.
    • A process can be loaded until the memory is empty.
  • No Limitation on the size of the process:

    • In Fixed partitioning, the process with the size greater than the size of the largest partition could not be loaded and process can not be divided as it is invalid in contiguous allocation technique.
    • Here, In variable partitioning, the process size can’t be restricted since the partition size is decided according to the process size.
  • Disadvantages of Variable Partitioning –

  • Difficult Implementation:

    • Implementing variable Partitioning is difficult as compared to Fixed Partitioning as it involves allocation of memory during run-time rather than during system configure.
  • External Fragmentation:
    • There will be external fragmentation inspite of absence of internal fragmentation.