English

Concepts related to memory management

Advertisements
  • Introduction to Memory Management
  • Partitioning 
  • Variable Partitions 
  • Paging
  • Segmentation
  • Virtual Memory

Concepts related to memory management

Memory Management is the last portion of the operating system. It performs following functions: 

  1. To keep track of all memory locations - free and allocated. 
  2. To decide memory allocation policy i.e. which process should get how much memory. 
  3. To use various techniques and algorithms to allocate and deallocate memory locations.

Memory map for single user computer 

 

The memory map for single user computer consists of kernel, command interpreter, the program to be executed and free available memory. Kernel of the operating system provides basic operating system services while command interpreter interprets operating system commands. 

Fixed Partitioning 

Partitioning divides main memory into sections called partitions. Fixed Partitioning is when those partitions are permanent. For example, a memory of 32 K words might be divided into regions of following sizes. 

 

As jobs enter the system, they are put in job queue. The job scheduler considers each job's memory requirement and available regions in determining which jobs are allocated memory. When a job is allocated space, it is loaded into the region. There may be a case where the allocated job's size is smaller than the memory which results in internal Fragmentation. 

Variable partitions 

In variable partitions the number of partitions and their sizes are variable. They are not defined at the time of system generation. At any given time, any partition can be free or allocated to some process. In variable partition the starting address of any partition is not fixed. Figure below shows variable partitions.  

 

Variable partition suffers from external fragmentation. Suppose a job of size 7 K is terminated. A job of 2 K size may be loaded and a partition of 5 K remains unused. This causes memory wastage, called external fragmentation. 

Paging 

A program's virtual address space and physical memory are divided into equal-sized pages and frames respectively. Pages fit exactly into frames so any page can be assigned to any page frame. 

 

Segmentation 

Segmentation is like paging. Pages are physical in nature and are of fixed size, whereas segments are logical divisions of program, and they are of variable sizes. For instance, each program in executable form can be considered as consisting of segments: code, data and stack. Each of the these can be further divided into further segments. In a program, normally we have a main program and some subprograms. There can be various functions like "SQRT" divided into segments. The segment table has a separate entry for each segment, giving the beginning address of the segment in physical memory and length of that segment. 

Virtual Memory 

Note: Virtual memory allows processes to run with parts stored on disk, enabling executing programs larger than physical memory. It decreases performance and is complex to implement. Following terms are commonly used with virtual memory: 

  1. Locality of reference: This is the basic principle behind virtual memory. In locality of reference, we forecast if a page is likely to be referenced soon, based on its past behavior.  
  2. Page fault: A page fault occurs when a process wants a page not in memory, prompting the operating system to load the required page from disk. 
  3. Working set: A process's working set is the set of actively used pages in physical memory. 
  4. Page replacement policy: As pages are bought in there may be a time when the memory is full, and a page is to be added. In this case, page replacement policy decides  which page should be replaced from the main memory.  
  5. Dirty page / Dirty bit: If the page is modified after loading into the memory, it is called as dirty page and is indicated by 1 bit. 
  6.  Demand Paging: In demand paging, a page is brought in only when demanded. 
If you would like to contribute notes or other learning material, please submit them using the button below.
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×