CONTIGUOUS ALLOCATION:
1.Introduction:
  • Main memory usually have two partitions-memory resident programs,user programs
  • Resident operating system, usually held in low memory with interrupt vector.
  • User processes then held in high memory.  Single-partition allocation
  • Relocation-register scheme used to protect user processes from each other, and from changing operating-system code and data.
  • Relocation register contains value of smallest physical address;
  •  limit register contains range of logical addresses – each logical address must be less than the limit register.  
2.Memory protection:

    
3.Memory allocation:       
  • Each process is contained in a single contiguous section of memory.
  • One of the simplest methods for memory allocation is to divide memory into several fixed-sized partitions. Each partition may contain exactly one process.
  • In multiple-partition method, when a partition is free, a process is selected from the input queue and is loaded into the free partition.
  • When the process terminates, the partition becomes available for another process.
  • The operating system keeps a table indicating which parts of memory are available and which are occupied.
  •   Depending on the method used, this approach can suffer from external as well as internal memory fragmentation.
  •      Hole – block of available memory; holes of various size are scattered throughout memory.
  • When a process arrives, it is allocated memory from a hole large enough to accommodate it.
  • Operating system maintains information about:
           a) allocated partitions b) free partitions (hole)
Three ways to fit a process in a hole:
  • 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.
  • How to satisfy a request of size n from a list of free holes.
    First-fit and best-fit better than worst-fit in terms of speed and storage utilization.
4.fragmentation
    4.1 internal fragmentation:allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used.
    4.2 external fragmentation:total memory space exists to satisfy a request, but it is not contiguous.
  • 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.
  • I/O problem
  • Latch job in memory while it is involved in I/O.
  • Do I/O only into OS buffers.

No comments:

Post a Comment