Presented By:
DEEPSHIKHA HARITWAL
MCA/25001/18
Contents
• Memory management
• Memory allocation techniques
• Contiguous memory allocation
• Non-contiguous memory allocation
Memory management
• Memory management is the functionality of an
operating system which handles or manages primary.
• Memory management keeps track of each and every
memory location, regardless of either it is allocated to
some process or it is free.
• It checks how much memory is to be allocated to
processes.
• It decides which process will get memory at what time.
• It tracks whenever some memory gets freed or
unallocated and correspondingly it updates the status.
Memory allocation techniques
• Memory allocation technique can be broadly
classified in two categories:
▫ Contiguous memory allocation
▫ Non- contiguous memory allocation
Contiguous Memory Allocation
• Contiguous memory allocation is the classical
memory allocation model in which each process
is allocated a single contiguous area in memory.
• Thus the kernel allocates a large enough
memory area to accommodate the code, data,
stack, and PCD data of a process.
• Contiguous memory allocation faces the
problem of memory fragmentation.
• Example :
• Processes A, B, C, and D are in memory.
• Two free areas of memory exist after B
terminates; however, neither of them is large
enough to accommodate another process.
• The kernel performs compaction to create a
single free memory area and initiates process E
in this area.
• It involves moving processes C and D in memory
during their execution.
•Contiguous memory allocation can
be:
▫Single partition allocation
▫Multiple partition allocation
Single partition algorithm
• In this type of allocation, relocation-register
scheme is used to protect user processes from
each other, and from changing operating-system
code and data.
• Relocation register contains value of smallest
physical address whereas limit register contains
range of logical addresses.
• Each logical address must be less than the limit
register.
Multiple partition allocation
• In Partition Allocation, when there are more
than one partition freely available to
accommodate a process’s request, a partition
must be selected.
• To choose a particular partition, a partition
allocation method is needed.
• A partition allocation method is considered
better if it avoids internal fragmentation.
• Various partition allocation schemes :
▫ First Fit: In the first fit, partition is allocated
which is first sufficient from the top of Main
Memory.
▫ Best Fit Allocate the process to the partition which
is first smallest sufficient partition among the free
available partition.
▫ Next Fit Next fit is similar to the first fit but it will
search for the first sufficient partition from the last
allocation point.
Non Contiguous Memory Allocation
• Modern computer architectures provide then on
contiguous memory allocation model, in which a
process can operate correctly even when
portions of its address space are distributed
among many areas of memory.
• This model of memory allocation permits the
kernel to reuse free memory areas that are
smaller than the size of a process, so it can
reduce external fragmentation.
• In Figure four free memory areas starting at
addresses 100K, 300K,450K, and 600K, where
K=1024, with sizes of 50 KB, 30 KB, 80 KB and
40KB, respectively, are present in memory.
• Process P, which has a size of 140 KB,is to be
initiated.
• If process P consists of three components called
P-1, P-2, and P-3, with sizes of 50 KB, 30 KB and
60 KB, respectively, these components can be
loaded into three of the free memory areas as
shown in figure.
•The logical address space of P extends from 0 to
140K−1,while the physical address space extends
from 0 to 640K−1.
•Data area xyz in the program of process P has the
address 51488. This is the logical address of xyz.
Managing Memory Allocation

Managing Memory Allocation

  • 1.
  • 2.
    Contents • Memory management •Memory allocation techniques • Contiguous memory allocation • Non-contiguous memory allocation
  • 3.
    Memory management • Memorymanagement is the functionality of an operating system which handles or manages primary. • Memory management keeps track of each and every memory location, regardless of either it is allocated to some process or it is free. • It checks how much memory is to be allocated to processes. • It decides which process will get memory at what time. • It tracks whenever some memory gets freed or unallocated and correspondingly it updates the status.
  • 4.
    Memory allocation techniques •Memory allocation technique can be broadly classified in two categories: ▫ Contiguous memory allocation ▫ Non- contiguous memory allocation
  • 5.
    Contiguous Memory Allocation •Contiguous memory allocation is the classical memory allocation model in which each process is allocated a single contiguous area in memory. • Thus the kernel allocates a large enough memory area to accommodate the code, data, stack, and PCD data of a process. • Contiguous memory allocation faces the problem of memory fragmentation.
  • 6.
    • Example : •Processes A, B, C, and D are in memory. • Two free areas of memory exist after B terminates; however, neither of them is large enough to accommodate another process. • The kernel performs compaction to create a single free memory area and initiates process E in this area. • It involves moving processes C and D in memory during their execution.
  • 7.
    •Contiguous memory allocationcan be: ▫Single partition allocation ▫Multiple partition allocation
  • 8.
    Single partition algorithm •In this type of allocation, relocation-register scheme is used to protect user processes from each other, and from changing operating-system code and data. • Relocation register contains value of smallest physical address whereas limit register contains range of logical addresses. • Each logical address must be less than the limit register.
  • 10.
    Multiple partition allocation •In Partition Allocation, when there are more than one partition freely available to accommodate a process’s request, a partition must be selected. • To choose a particular partition, a partition allocation method is needed. • A partition allocation method is considered better if it avoids internal fragmentation.
  • 11.
    • Various partitionallocation schemes : ▫ First Fit: In the first fit, partition is allocated which is first sufficient from the top of Main Memory. ▫ Best Fit Allocate the process to the partition which is first smallest sufficient partition among the free available partition. ▫ Next Fit Next fit is similar to the first fit but it will search for the first sufficient partition from the last allocation point.
  • 13.
    Non Contiguous MemoryAllocation • Modern computer architectures provide then on contiguous memory allocation model, in which a process can operate correctly even when portions of its address space are distributed among many areas of memory. • This model of memory allocation permits the kernel to reuse free memory areas that are smaller than the size of a process, so it can reduce external fragmentation.
  • 14.
    • In Figurefour free memory areas starting at addresses 100K, 300K,450K, and 600K, where K=1024, with sizes of 50 KB, 30 KB, 80 KB and 40KB, respectively, are present in memory. • Process P, which has a size of 140 KB,is to be initiated. • If process P consists of three components called P-1, P-2, and P-3, with sizes of 50 KB, 30 KB and 60 KB, respectively, these components can be loaded into three of the free memory areas as shown in figure.
  • 15.
    •The logical addressspace of P extends from 0 to 140K−1,while the physical address space extends from 0 to 640K−1. •Data area xyz in the program of process P has the address 51488. This is the logical address of xyz.