Memory Management
Memory Management
Memory Management
• Memory management is the functionality of an operating
system which handles or manages primary memory and
moves processes back and forth between main memory and
disk during execution.
Load time – If it is not known at the compile time where process will
reside then relocatable address will be generated. Loader translates
the relocatable address to absolute address. The base address of the
process in main memory is added to all logical addresses by the loader
to generate absolute address. In this if the base address of the
process changes then we need to reload the process again.
Execution time/Run time- The instructions are in memory and
are being processed by the CPU. Additional memory may be
allocated and/or deallocated at this time. This is used if
process can be moved from one memory to another during
execution(dynamic linking-Linking that is done during load or
run time). e.g – Compaction.
1. Best - Fit
2. Worst -
fit 3. First
- fit
Best - Fit - chooses a partition that is
smallest and whose size is greater than equal to k.
It leaves small-sized unusable partitions or
holes.
First - fit - chooses the first
partition whose size is greater than
equal to k.
Worst - fit - chooses the largest
partition and allocates it to process p. It
can leave bigger unusable partitions.
Compaction means to move the processes in the
memory in such a way that scattered pieces of
unused (free) memory can be placed together so
that any other process demanding contiguous
memory for it can use it.
Non-contiguous Storage
► To resolve Allocation
the problem of external fragmentation
and to enhance the degree of multiprogramming
to a greater extent, it was decided to sacrifice the
simplicity of allocating contiguous memory to every
process.
► It was decided to have a non-contiguous physical
address space of a process so that a process could be
allocated memory wherever it was available.
Non- contiguous Storage Allocation
There are 2 techniques for non- contiguous allocation:
1. Paging
2. Segmentation
1. Paging
• In this approach, physical memory is divided into fixed-size
blocks called frames and the logical memory is divided
into the fixed-sized blocks called pages.