Memory Management
Memory Management
Variable Partitioning
• It is a part of Contiguous allocation technique.
• It is used to alleviate the problem faced by Fixed Partitioning.
• In contrast with fixed partitioning, partitions are not made before the execution
or during system configure.
• Various features associated with variable Partitioning-
1. Initially RAM is empty and partitions are made during the run-time
according to process’s need instead of partitioning during system configure.
2. The size of partition will be equal to incoming process.
3. The partition size varies according to the need of the process so that the
internal fragmentation can be avoided to ensure efficient utilisation of RAM.
4. Number of partitions in RAM is not fixed and depends on the number of
incoming process and Main Memory’s size.
In Figure-2, the free space list head points to Block 5 which points to Block 6, the next
free block and so on. The last free block would contain a null pointer indicating the end
of free list. A drawback of this method is the I/O required for free space list traversal.
• Each process is divided into parts where size of each part is same as page size.
• The size of the last part may be less than the page size.
• The pages of process are stored in the frames of main memory depending upon
their availability.
Advantages-
The advantages of paging are-
It allows to store parts of a single process in a non-contiguous fashion.
It solves the problem of external fragmentation.
Disadvantages-
The disadvantages of paging are-
• It suffers from internal fragmentation.
• There is an overhead of maintaining a page table for each process.
• The time taken to fetch the instruction increases since now two memory accesses
are required.
Page Table-
• Page table is a data structure.
• It maps the page number referenced by the CPU to the frame number where that
page is stored.
Characteristics-
• Page table is stored in the main memory.
• Number of entries in a page table = Number of pages in which the process is
divided.
• Page Table Base Register (PTBR) contains the base address of page table.
• Each process has its own independent page table.
• Page Table Base Register (PTBR) provides the base address of the page table.
• The base address of the page table is added with the page number referenced by
the CPU.
• It gives the entry of the page table containing the frame number where the
referenced page is stored.
Segmentation:
• Segmentation is a memory management technique in which each job is divided
into several segments of different sizes, one for each module that contains pieces
that perform related functions.
• Each segment is actually a different logical address space of the program.
• When a process is to be executed, its corresponding segmentation are loaded into
non-contiguous memory though every segment is loaded into a contiguous block
of available memory.
• Segmentation memory management works very similar to paging but here
segments are of variable-length where as in paging pages are of fixed size.
• The operating system maintains a segment map table for every process and a list
of free memory blocks along with segment numbers, their size and corresponding
memory locations in main memory.
• For each segment, the table stores the starting address of the segment and the
length of the segment.
• A reference to a memory location includes a value that identifies a segment and
an offset.
• Segment Table – It maps two-dimensional Logical address into onedimensional
Physical address. It’s each table entry has:
1. Base Address: It contains the starting physical address where the segments
reside in memory.
2. Limit: It specifies the length of the segment.
Fragmentation:
• As processes are loaded and removed from memory, the free memory space is
broken into little pieces.
• It happens after sometimes that processes cannot be allocated to memory blocks
considering their small size and memory blocks remains unused.
• This problem is known as Fragmentation.
Fragmentation is of two types –
S.N. Fragmentation & Description
External fragmentation: Total memory space is enough to satisfy a request or to reside
1
a process in it, but it is not contiguous, so it cannot be used.
Internal fragmentation: Memory block assigned to process is bigger. Some portion of
2
memory is left unused, as it cannot be used by another process.
Page Fault:
• A page fault occurs when a program attempts to access a block of memory that
is not stored in the physical memory, or RAM.
• The fault notifies the operating system that it must locate the data in virtual
memory, then transfer it from the storage device, such as an HDD or SSD, to the
system RAM.
Initially all slots are empty, so when 1, 3, 0 came they are allocated to the empty slots
—> 3 Page Faults. when 3 comes, it is already in memory so —> 0 Page Faults.
Then 5 comes, it is not available in memory so it replaces the oldest page slot i.e 1. —
>1 Page Fault.
6 comes, it is also not available in memory so it replaces the oldest page slot i.e 3 —>1
Page Fault.
Finally when 3 come it is not available so it replaces 0 1 page fault
Hence Fage Fault Ratio = 6/7 = 0.85
Initially all slots are empty, so when 7 0 1 2 are allocated to the empty slots —> 4 Page faults
0 is already there so —> 0 Page fault.
when 3 came it will take the place of 7 because it is not used for the longest duration of time
in the future.—>1 Page fault.
0 is already there so —> 0 Page fault..
4 will takes place of 1 —> 1 Page Fault.
Now for the further page reference string —> 0 Page fault because they are already available
in the memory.
Optimal page replacement is perfect, but not possible in practice as the operating system
cannot know future requests. The use of Optimal Page replacement is to set up a benchmark
so that other replacement algorithms can be analyzed against it.