Memory Management (Contiguous and Non-Contiguous ).

               MEMORY MANAGEMENT


Background:

  • Memory consists of a large array of words or bytes, each with its own address.
  • The CPU fetches instructions from memory according to the value of the program counter.
  • These instructions may cause additional loading from and storing to specific memory addresses.
  • Just as processes share the CPU, they also share physical memory
  • Memory management is subdividing memory to accommodate multiple processes. 
  • Memory needs to be allocated to ensure a reasonable supply of ready processes to consume available processor time.

Memory Allocation:

There are two types of memory allocation techniques:
  1. Contiguous.
  2. Non - Contigous.

1.Contiguous Memory Allocation:

  1. Fixed size partitioning .
  2. Dynamic Partitioning .

Fixed size partitioning - (Causes internal fragmentation):


Each partition contain exactly one process. Degree of multiprogramming bound by # of partitions
–A program may not fit in a partition. The programmer must design the program with overlays
–Main memory use is inefficient. Any program, no matter how small, occupies an entire partition
•This is called internal fragmentation.




Dynamic size partitioning - (Causes External fragmentation):



Multiple-partition allocation:

  • Partitions are of variable length and number
  • Process is allocated exactly as much memory as required. i.e., When a process arrives, it is allocated memory from a hole large enough to accommodate it.
  • Hole – block of available memory; holes of various size are scattered throughout memory.
  • Operating system maintains information about: a) allocated partitions b) free partitions (hole)





Dynamic Storage-Allocation Problem

How to satisfy a request of size n from a list of free holes.

•First-fit: Allocate the first hole that is big enough.
•Best-fit: Allocate the smallest hole that is big enough; must search entire list, unless ordered by size. Produces the smallest leftover hole.
•Worst-fit: Allocate the largest hole; must also search entire list. Produces the largest leftover hole.


First-fit and best-fit better than worst-fit in terms of speed and storage utilization. But, first fit is generally faster 

external fragmentation :- Eventually get holes in the memory.


Fragmentation:

•External Fragmentation – total memory space exists to satisfy a request, but it is not contiguous.

•Internal Fragmentation – allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used.

•Reduce external fragmentation by compaction
–Shuffle memory contents to place all free memory together in one large block.
–Compaction is possible only if relocation is dynamic, and is done at execution time.
•Another possible solution to the external fragmentation is to permit the logical-address space of a process to be noncontiguous – paging, segmentation


Comments

Popular posts from this blog

FC Barcelona vs Real Madrid -El Clasico Rivalry.

1NF,2NF, 3NF Normalization