Memory management and its allocation to numerous processes are one of the essential functions of the operating system. We have discussed the process address space, loading and linking in the previous piece of informative writing. In this blog, you can equate yourself with the various phenomenon included in the allocation of memory by the operating system.
The allocation mechanism plays an essential role in the fragmentation process. It does not allow the allocation of the memory to the processes instead of the availability of the sufficient memory. The mechanism of the memory allocation which suffers from fragmentation is the contiguous memory allocation. As a result, the process leads to the inefficient use of available memory. The free memory space is broken down into little pieces as the methods are loaded as well as removed from the memory. Sometimes, there is no allocation of memory to the processes. The memory blocks are considered as the small size that is why they remain unused. The name of the problem is fragmentation.
1. External Fragmentation-
There is enough memory space to satisfy the needs and the requests of the processes. But the total memory space is not contiguous, and that is why it can’t be used.
A technique to reduce the external fragmentation- Compact or shuffle the contents of the memory to put all the free memory together in one large block. The relocation of the memory should be dynamic to make the compaction process feasible.
2. Internal Fragmentation-
A large block of memory is assigned to a process. Most of the times, it is not utilized to the fullest. Some part of the memory is left unused because no other method can use it.
A technique to reduce the internal fragmentation- Assign the smallest but enough portion of memory to the process.
Addressing more memory than the amount of memory physically installed on the system is also feasible in the computer. The name given to this extra memory is the virtual memory. This portion of the memory is set for the emulation process of the RAM of the computer. The implementation of the virtual memory needs the paging technique for its operation to occur.
The technique of managing the memory during the process of the breakdown of the blocks of the same size is called paging. The blocks which are used here are termed as pages. All of them are of the same size and lie between the range of 512 bytes and 8192 bytes. The number of the pages is the parameter to measure the size of the process.
The blocks of the small-fixed size of the physical memory are called as frames. The main memory is divided into frames. The size of the structures is same as that of the pages. It is required to have the high optimum utilization of the main memory. Avoiding the external fragmentation is also one of the motives of the breakdown of the main memory.
Translation of address
Logical addresses are called as the page address. They are represented as a combination of both the page number and the offset. Whereas, the physical addresses are the frame address. Here, frames have replaced the pages, and the offset remains the same in the equation.
Page Map table is a data structure which is used to keep track of the processes of the pages and the frame in the physical memory as well as their relation between the two.
When any page gets the frame from the system, it also translates the logical addresses to the physical addresses. In addition to this process, the creation of the entry into the page table to use throughout the program execution is also the task of the system.
The corresponding pages are loaded into the available memory frames for the execution of the process. In simple words, consider that a program which you want to execute has a memory of 10 Kb, but the corresponding memory which is there for its allocation then is only 7Kb. In this situation, the concept which would come into the picture is paging. The OS moves to the unwanted pages of the memory to the secondary memory or the idle situation every time the computer runs out of RAM.
The process goes on during the entire process of program execution. It is the process in which the operating system keeps on removing the idle pages from the main memory. Also, it writes the idle pages onto the secondary memory and then brings them back every time any program needs them.
Advantages and Disadvantages of Paging
The process has various benefits and detriments.
The list is as follows.
- The advantage of paging- The process results in the reduction of the external fragmentation.
- Disadvantage- Instead of reducing the external fragmentation, the process suffers from the internal fragmentation.
- Advantage- Easy and straightforward implementation process.
- Another benefit of the process is that it is assumed to be a useful technique for the management of the memory.
- It also leads to the ease of the swapping process. It can achieve only due to the corresponding page as well as frame size.
- Disadvantage- The page table needs some extra memory space. This is not sufficient for the system which has small RAM.
The memory management technique to divide each job into several segments with varied sizes is called segmentation. In this process, every module performs related functions and is contained in the pieces of the job.
Every time there is an execution of the process, there is the loading of the corresponding segmentation into the non-contiguous memory. But the loading process takes place in the available contiguous block memory.
There are various similar functions of the segmentation memory management and the paging. But the length of the segments is varied. On the other hand, the pages have the same sizes.
The elements of the program segment are as follows-
- The primary function of the program
- Utility function
- Data structures
There are several other resources and the features of the list.
In addition to this, the segment map table for every process is maintained by the operating system. Also, the list of the free blocks plus the number of the segments in addition to the sizes as well as their corresponding memory locations in the main memory are handled by the operating system. The table stores the beginning address of the segment. It happens for every section. The length of the part is also stored. There is a reference to the memory. It includes the identifying value of the section as well as the offset.