Memory Management
Memory Management
Memory Management
Memory Manager :
The logical address is a virtual address as it does not exist physically, therefore, it is also known
as Virtual Address.
This address is used as a reference to access the physical memory location by CPU.
The term Logical Address Space is used for the set of all logical addresses generated by a
program’s perspective.
The hardware device called Memory-Management Unit is used for mapping logical addresses to
its corresponding physical address.
Physical Address
The user never directly deals with the physical address but can access by its corresponding logical
address.
The user program generates the logical address and thinks that the program is running in this
logical address but the program needs physical memory for its execution, therefore, the logical
address must be mapped to the physical address by MMU before they are used.
The term Physical Address Space is used for all physical addresses corresponding to the logical
program. addresses.
User can view the logical User can never view physical
Visibility
address of a program. address of program.
The user can use the logical The user can indirectly access
address. directly.
A page, memory page, or virtual page
In static memory allocation, the size of the data required by the process must be known
before the execution of the process initiates.
Static memory allocation provides more efficiency when compared by the dynamic
memory allocation.
2. Dynamic Memory Allocation
Dynamic memory allocation is performed while the program is in execution. Here, the
memory is allocated to the entities of the program when they are to be used for the first
time while the program is running.
The actual size, of the data required, is known at the run time so, it allocates the exact
memory space to the program thereby, reducing the memory wastage.
Allocating memory dynamically creates an overhead over the system. Some allocation
operations are performed repeatedly during the program execution creating more
overheads, leading in slow execution of the program.
Dynamic memory allocation does not require special support from the operating
system.
Thus the dynamic memory allocation is flexible but slower than static memory
allocation.
Fragmentation
● After the partitioning/memory allocation of memory comes the fragmentation.
● When the processes are loaded to and removed from memory, the memory space
that gets freed breaks into little pieces.
● Now, when this happens, no further processes can be allotted memory as their
size becomes too small for that, and hence the memory blocks remain unused.
● The solution to this problem is known as fragmentation.
● In other words, fragmentation can be defined as the issue of a memory that arises
when processes are loaded to and removed from the memory, breaking it into
pieces.
● The fragmentation is mainly of two types:
1. External fragmentation – In external fragmentation, the total memory space
is enough to satisfy a request or to reside a process in it. But it is not
contiguous, so it cannot be used.
2. Internal fragmentation – In internal fragmentation, the memory block
assigned to processes is bigger. Some portion of the memory may be left
unused, as it cannot reside in any other process.
Segmentation
In Operating Systems, Segmentation is a memory management technique in which, the memory is
divided into the variable size parts. Each part is known as segment which can be allocated to a
process.
The details about each segment are stored in a table called as segment table. Segment table is
stored in one (or many) of the segments.
Operating system doesn't care about the User's view of the process. It may divide the same
function into different pages and those pages may or may not be loaded at the same time into the
memory. It decreases the efficiency of the system.
It is better to have segmentation which divides the process into the segments. Each segment
contain same type of functions such as main function can be included in one segment and the
library functions can be included in the other segment,
1. Segment Number
2. Offset
The Segment number is mapped to the segment table. The limit of the respective segment is
compared with the offset. If the offset is less than the limit then the address is valid otherwise it
throws an error as the address is invalid.
In the case of valid address, the base address of the segment is added to the offset to get the
physical address of actual word in the main memory.
Advantages of Segmentation
1. No internal fragmentation
3. Less overhead
5. The segment table is of lesser size as compare to the page table in paging.
Disadvantages
1. It can have external fragmentation.