The main difference between fragmentation and segmentation is that the fragmentation is a condition that causes memory blocks to remain unused while segmentation is the technique of dividing a process into several modules or sections.
Fragmentation and segmentation are two terms associated with memory management. Where, memory management is one major task performed by an operating system. It manages memory by moving processes back and forth between the main memory and disk during execution. Certain memory locations can be allocated to a process or deallocated from a process. Hence, the OS keeps all the records of the memory locations of the processes. It also checks the amount of memory allocated to processes. In addition, it decides which process should get memory at what time. Furthermore, the OS updates the status of memory locations, i.e., whether they are free or allocated to processes.
Key Areas Covered
1. What is Fragmentation
– Definition, Functionality
2. What is Segmentation
– Definition, Functionality
3. Difference Between Fragmentation and Segmentation
– Comparison of Key Differences
Key Terms
External Fragmentation, Fragmentation, Internal Fragmentation, Memory Management, Operating System, Segmentation
What is Fragmentation
When executing a process, it is loaded into the memory. After completing the execution, it is removed from the memory. Process loading and removing create free spaces in memory. These spaces are small in size and cannot be allocated for some other process. Therefore, those memory blocks remain unused. It is called fragmentation. There are two types of fragmentation called internal fragmentation and external fragmentation.
Internal Fragmentation
In internal fragmentation, the memory block allocated to a process is larger than required. It causes some portion of memory to left unused. This left space cannot be allocated to another process. For example, if a process requires 2MB but it is allocated to a 3MB memory block, then 1MB block is left unused. This 1MB cannot be allocated to some other process, and it is a waste.
External Fragmentation
In external fragmentation, the total memory space is enough to locate a process, but it is not contiguous. Therefore, that space remains unused. For example, assume that there is a process of 3MB and there are three memory blocks located in different memory locations. Those blocks cannot be used for the process as they are not contiguous. Shuffling memory is a solution to this issue. It helps to place all free memory space to one lactation.
What is Segmentation
Segmentation divides each process into several segments or sections of different sizes. A segment can be a main program, function, stacks, symbol tables, data structures, etc. Every segment is a different logical address space of the program. These segments are of variable length size. In other words, the segments are not fixed in size.
When executing the program, each segment is loaded into non-contiguous memory. A reference to a memory location of a segment includes the segment number and the offset. The OS maintains a table called segment map table. It is also called the local descriptor table. This table stores records of every process and free memory blocks. It consists of the starting address (base address) and the length of every segment.
Difference Between Fragmentation and Segmentation
Definition
Fragmentation is a phenomenon in which storage space is used inefficiently, reducing capacity or performance and often both. Segmentation is the process of dividing the computer’s primary memory into segments or sections.
Functionality
While fragmentation cause memory blocks to remain unused, segmentation works as a memory management technique to execute processes.
Conclusion
Fragmentation and segmentation are associated with memory management. The difference between fragmentation and segmentation is that fragmentation is a condition that causes memory blocks to remain unused while segmentation is the technique of dividing a process into several modules or sections.
Reference:
1. Introduction of Segmentation | Operating System |, Education 4u, 9 May 2018, Available here.
2. “Operating System Memory Management.” Www.tutorialspoint.com, Tutorials Point, Available here.
Image Courtesy:
1. “Protected mode segments” By John Källén (jkl at commons) – Own work (Public Domain) via Commons Wikimedia
Leave a Reply