Memory Management

 

Memory Management


  • Allocates physical memory to processes
  • Tracks of allocated and available memory locations
  • Manages Virtual Memory, etc

    Terminology

  • The terms Primary Memory, Main Memory & Physical Memory refer to RAM
  • Secondary Memory refers to storage devices, such as hard drives and solid state drives.

    Memory Allocation

  • Ensure that each process can only access the address space allocated to it
  • Restrict access to address space outside its allocated space

    Memory allocation is a process by which computer programs are assigned memory.

  • Contiguous Memory Allocation
  • Non-Contiguous Memory Allocation

    Contiguous Memory Allocation

    A single contiguous section of memory blocks is assigned to the process according to its requirement.

    Memory is also allocated as blocks of fixed sizes.

    Fragmentation

    Memory is used inefficiently, reducing capacity & performance.
    Types of Fragmentation:

    • External Fragmentation
    • Internal Fragmentation

    External Fragmentation

Total memory space is enough to satisfy a request, but cannot be used as it is not contiguous.

Internal Fragmentation


Process is allocated a memory block of size more than the size of that process. Due to this some part of the memory is left unused and this cause internal fragmentation.

Non-Contigous Memory Allocation


Assigns different blocks of memory in a non consecutive manner to a process.

  • Paging
  • Segmentation

    Memory Management Unit

    The run time mapping between Virtual address and Physical Address is done by hardware device known as MMU.

    Paging

  • Logical Memory is divided into equal fixed size partitions called pages.
  • Each of this pages corresponds to a frame in physical memory.

    Logical Address

    The generated logical address can be broken into two parts

  • Page Number
  • Page Offset

    Different parts of the same process can be stored at different places in the main memory.

    Consider Page Size of 1000 bytes,

    Logical Address Location 4020 = Page 4, Offset 20

Page Table

Maps the page number referenced by the CPU to the frame number where that page is stored.

  • Each process has its own independent page table.

Paging

  • Frame number specifies the specific frame where the required page is stored.

  • Page Offset specifies the specific word that has to be read from that page

Virtual Memory

  • Virtual memory is a memory management technique that creates an illusion to users of larger physical memory.

  • Ability to execute partially-loaded program.
  • When using virtual memory, logical address is also referred as virtual address.

  • The secondary memory used is also referred to as swap space.

Swapping

Moving memory of a process between Primary Memory and Secondary Memory is called Swapping

  • Swap In the currently executing process

  • Swap Out the least required process

Demand Paging

  • Pages are loaded only on demand, not in advance.

  • Page referred for the first time in the main memory, then that page will be found in the secondary memory.

Page Replacement Algorithm

Page replacement algorithm decides which page to remove when a new page needs to be loaded into the primary memory.

Page Replacement Algorithms :

  • Least Recently Used (LRU)

  • Least Frequently Used (LFU)

    and many more...

  • If a process requests for page and that page is found in the main memory then it is called page hit.

  • If page is not found in memory then it is page miss or page fault.

LRU Algorithm

  • Least Recently Used (LRU) page.

  • It replaces the page that has not been used for the longest period of time.

LFU Algorithm

  • Page with the minimum no. of previous hits is selected for replacement.

  • If counts are equal than it applies FIFO.


Post a Comment

Please Select Embedded Mode To Show The Comment System.*

Previous Post Next Post

Contact Form