Last Updated on March 15, 2023 by Prepbytes
When a process is loaded and unloaded from memory repeatedly, the free memory space becomes fragmented, which is an undesirable OS issue known as fragmentation. Due to their small size, the memory blocks cannot be assigned to the processes. As a result, the memory blocks are never used.
Let us discuss more about fragmentation in detail:
What is Fragmentation?
When the system’s memory is insufficiently employed for the purpose of storing information, it results in fragmentation, which lowers the system’s overall efficiency, capability, or both (sometimes). The effects of the fragmentation process fully depend on the operation’s individual storage space allocation plans and the precise types of fragmentation.
Fragmentation can occasionally result in some wasted storage space. The produced unused space in this case is also subject to this idea.
No matter how much fragmentation there is, the RAM utilized to store the data set (like file formats) is quite similar to that of other systems (like the FAT file system) (it happens from null to the extreme).
Types of Fragmentation:
In an Operating system, internal and external fragmentation are two different types of fragmentation.
- The internal fragmentation
- The external fragmentation
1. Internal Fragmentation in OS:
Internal fragmentation in OS occurs when memory is divided into blocks of varying size. The mounted-sized block is assigned to a method each time a memory request for a method is made. Internal fragmentation refers to the situation where the method is given a memory allotment that is somewhat bigger than the memory requested. The memory block sizes were the problem, which we corrected. This problem can be resolved if we allocate space to the process via dynamic partitioning.
A process-specific memory block is larger in internal fragmentation. As it cannot be used by another process, some memory is left unused. Moreover, internal fragmentation is a problem that arises when memory is partitioned into fixed-sized units. By choosing the smallest partition that is yet big enough.
2. External Fragmentation in OS:
The empty space between non-contiguous memory chunks is known as external fragmentation. These unoccupied areas are too few to support a new procedure. Although the entire memory space is sufficient to accommodate a request or a process, it cannot be used since it is not contiguous.
When memory is partitioned into units of varying sizes, external fragmentation results. The sizes of the processes have an impact on these partitions’ size.
Compaction and memory content shuffles to group all the free memory into one big block can both reduce external fragmentation. Relocation must be dynamic to allow for compaction.
Difference between Internal and External Fragmentation:
Below is the difference between internal fragmentation in OS and external fragmentation in OS as a tabular form
Internal Fragmentation | External Fragmentation |
---|---|
1. The problem is known as internal fragmentation when there is a discrepancy between the required memory space and the allocated memory space. | 1. The issue is known as external fragmentation when there are small, non-contiguous memory chunks that cannot be assigned to any process. |
2. Internal fragmentation happens when memory chunks are allotted that have a predetermined size. | 2. External Fragmentation happens when memory blocks are allotted but are of different sizes. |
3. Internal fragmentation happens when a process uses less space or requires more space than the size of the memory block given to it. | 3. When a process is deleted from the main memory, external fragmentation happens. |
4. The remedy for internal fragmentation is Best Fit Block Search. | 4. The answer to external fragmentation is compaction. |
5. When paging is used, internal fragmentation happens. | 5. When segmentation is used, external fragmentation takes place. |
Advantages of Fragmentation:
Some of the advantages of Fragmentation in OS are:
- Fragmentation can help maximize the use of available storage space by allocating small blocks of free space to store data.
- Fragmentation allows for files of different sizes to be stored on the disk.
- This flexibility can be especially useful in situations where file sizes vary widely.
- Fragmentation can result in faster access times for small files because they can be stored in smaller clusters.
Disadvantages of Fragmentation:
The main disadvantages of fragmentation include:
- Fragmentation can lead to slower access times for large files because they are stored in non-contiguous clusters, requiring more time to access them.
- Fragmentation can lead to increased wear and tear on the disk drive because the read/write head has to move around more to access the data.
- Fragmentation can increase the risk of data loss because it can make it more difficult to recover data from a damaged or corrupted disk.
- Fragmentation can increase system overhead by requiring more time and resources to manage the scattered data on the disk.
Conclusion:
The most important distinction to make in this case is that internal memory fragmentation happens when memory blocks are assigned that are a constant size, but external memory fragmentation occurs when memory blocks are allotted that are variable sizes.
Frequently Asked Questions(FAQ):
1. How can operating system fragmentation be reduced?
For the purpose of minimizing external fragmentation, a large block of free memory can be produced using compaction or memory shuffle. Compaction cannot function without dynamic relocation. Internal fragmentation can be reduced by effectively allocating the lowest division that is still big enough for the task.
2. Can OS totally avoid fragmentation?
Data fragmentation can be minimized by reorganizing storage so that similar portions are close to one another, just as compaction can eliminate external fragmentation.
3. What source is the cause of fragmentation?
Fragmentation can only take place on the source host, which means a packet can only be fragmented once. Routers or other network devices cannot fragment packets.
4. Why does internal system fragmentation happen?
When we partition the physical memory into contiguous mounted-sized chunks and allocate memory for a process that may be larger than the requested memory, internal fragmentation occurs. As a result, other programs can no longer utilize the unused space.