MEMORY
MANAGEMENT
MEMORY MANAGEMENT
Memory manager is used to keep track of the status of memory locations,
whether it is free or allocated.
Memory manager permits computers with a small amount of main memory
to execute programs larger than the size or amount of available memory.
It does this by moving information back and forth between primary memory
and secondary memory by swapping.
• The memory manager is responsible for protecting the memory allocated to
each process from being corrupted by another process.
• Memory managers should enable sharing of memory space between
processes.
MEMORY MANAGEMENT
MEMORY MANAGEMENT
Contiguous memory allocation is a method in which a single contiguous section/part of
memory is allocated to a process or file needing it.
All the available memory space resides in the same place together, which means that the
freely/unused available memory partitions are not distributed in a random fashion here and
there across the whole memory space.
MEMORY MANAGEMENT
Advantages of Contiguous Memory Allocation
Faster Execution: Less time is consumed in the execution of
processes due to the fact that memory is provided in a sequential
manner.
Minimal Overhead: There are fewer address translations, which
all contribute to the efficiency of the system.
Easier to Control: Organization of the memory in the operating
system is sequential, which makes it possible to have efficient
control of the processes.
MEMORY MANAGEMENT
Disadvantages of Contiguous Memory Allocation
Limited Multiprogramming: The disadvantage of fixed
partitioning is that it hinders the ability to control and
allocate several processes.
Wastage of Memory: With fixed partitions, memory can
be wasted, especially where its usage is not optimal as
required.
MEMORY MANAGEMENT
Non-Contiguous memory allocation is a method on the contrary to contiguous
allocation method, allocates the memory space present in different locations to
the process as per it’s requirements.
All the available memory space is in a distributed pattern so the freely
available memory space is also scattered here and there. This technique of
memory allocation helps to reduce the wastage of memory.
MEMORY MANAGEMENT
Advantages of Non-Contiguous Memory Allocation
No Memory Wastage: Dynamic allocation makes sure that memory is used as
is available and that there is no memory wasted.
Increased Multiprogramming: Non-contiguous allocation where higher
degrees of multiprogramming are feasible.
Disadvantages of Non-Contiguous Memory Allocation
Slower Execution: Tasks could be longer in duration because memory is
frequently split into blocks.
MEMORY ADDRESSES
Symbolic addresses
The addresses used in a source code. The variable names, constants, and instruction labels are
the basic elements of the symbolic address space.
Relative addresses
At the time of compilation, a compiler converts symbolic addresses into relative addresses
Physical addresses
The loader generates these addresses at the time when a program is loaded into main memory.
PAGING
Paging is a storage mechanism used to retrieve processes from the secondary storage into the
main memory in the form of pages.
The paging is to divide each process in the form of pages.
The main memory will also be divided in the form of frames.
One page of the process is to be stored in one of the frames of the memory. The pages can be
stored at the different locations of the memory but the priority is always to find the contiguous
frames(FREE SPACE)
Pages of the process are brought into the main memory only when they are required otherwise
they reside in the secondary storage.
PAGE SIZE=FRAME SIZE
PAGING
Different operating system defines different frame sizes. The sizes of each
frame must be equal.
PAGING
Let us consider the main memory size 16 Kb and Frame size is 1 KB therefore the main
memory will be divided into the collection of 16 frames of 1 KB each.
There are 4 processes in the system that is P1, P2, P3 and P4 of 4 KB each. Each process is
divided into pages of 1 KB each so that one page can be stored in one frame.
Initially, all the frames are empty therefore pages of the processes will get stored in the
contiguous way.
PAGING
PAGING
Memory Management Unit
The purpose of Memory Management Unit (MMU) is to convert the logical address into the
physical address.
The logical address is the address generated by the CPU for every page
The physical address is the actual address of the frame where each page will be stored(Main memory)
When a page is to be accessed by the CPU by using the logical address, the operating system needs to
obtain the physical address to access that page physically.
The logical address has two parts.
Page Number
Offset
Memory management unit of OS needs to convert the page number to the frame number.