Memory Allocation Techniques - aryanjoshi0823/5143-Operating-System GitHub Wiki

Memory Management is a critical function of an operating system (OS) that handles the allocation, tracking, and optimization of a computer's memory resources. It ensures that processes can efficiently use memory while maintaining system stability and performance.

Techniques:

a) Contiguous Allocation

Contiguous memory allocation is a strategy where each process is assigned a single continuous block of memory. When a process requests access to memory, a contiguous segment is allocated from the free space, based on the process size.

1. Fixed Partition Scheme

  • Memory is divided into a fixed number of partitions, with each partition accommodating only one process.

  • Characteristics:

    • Multi-programming is limited by the number of partitions.
    • Process size cannot exceed the partition size.
    • Each partition is associated with limit registers:
      • Lower Limit: Starting address.
      • Upper Limit: Ending address.
  • Internal Fragmentation: Unused memory within a partition leads to wasted space.

2. Variable Partition Scheme

  • Memory starts as a single continuous block and is dynamically divided into partitions based on process size.

  • Characteristics:

    • Memory is divided as per the size of incoming processes.
    • One partition is allocated to each active process.
  • External Fragmentation: Scattered free memory blocks lead to inefficiency.


b) Non-Contiguous Memory Allocation

Non-contiguous memory allocation allows a process to obtain multiple memory blocks located in different areas of memory, based on its requirements. This technique helps utilize memory more efficiently by reducing wastage caused by internal and external fragmentation. It uses memory holes created by these fragmentations, making better use of available resources.

How Non-Contiguous Memory Allocation Works

  • Processes are divided into blocks (e.g., pages or segments) and allocated to different areas of memory based on availability.
  • The physical address space of a process becomes non-contiguous, requiring address translation to map logical addresses to physical ones.

Methods for Non-Contiguous Memory Allocation

  1. Paging:

    • Divides memory into fixed-sized blocks called frames and divides processes into fixed-sized pages.
    • Pages are mapped to available frames using a page table.
  2. Segmentation:

    • Divides memory into variable-sized logical units called segments based on the program's structure (e.g., code, data, stack).
    • Segments are mapped to memory using a segment table.