- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is Segmentation?
Segmentation is another approach of allocating memory that can be used rather than or in conjunction with paging. In its purest form, a program is broken into multiple segments, each of which is a self-contained unit, including a subroutine or data structure.
Unlike pages, segments can vary in size. This requires the MMU to manage segmented memory somewhat differently than it would manage paged memory. A segmented MMU contains a segment table to maintain track of the segments resident in memory.
A segment can create at one of many addresses and can be of any size, each segment table entry should contain the start address and segment size. Some system allows a segment to start at any address, while other limits the start address. One such limit is found in the Intel X86 architecture, which requires a segment to start at an address that has 6000 as its four low-order bits.
A system with this limitation would not need to store these four bits in its segment table, since their value is implicit. As shown in the figure, it shows a simplified address translation scheme for segmented memory.
The offset is compared to the segment size. If the offset is higher than or the same as the segment size, signifying that the location is not a part of the segment, an error is created. If the offset has a true value, it is inserted to the beginning of the segment address to create the correct physical memory addresses. As with paging, a segmented MMU can also have a TLB to speed up the generation of segment start addresses and sizes.
In paging, the page number is sent to the page table (and TLB) to produce a frame number. This value is concatenated with the offset to produce the physical address. In segmentation, the start address generated by the segment table or TLB is added to the offset, a process much more time-consuming than concatenation.
Because segments can have different sizes, this method has both advantages and disadvantages as compared to paging. Consider the paging example for the relatively simple CPU.
In the paged memory execution, each page is of size 4K. A program of size 4K + 1 would need the MMU to allocate two pages of memory, even though the second page would use only one of its 4K locations. This is referred to as internal fragmentation. If segmentation is used, a segment of exactly size 4K + 1 can be allocated, thus avoiding this problem.
Segmentation has a problem known as external fragmentation. There are three segments resident in memory and 8K of free space. The free is subdivided such that no segment higher than 3K can be loaded into memory without changing or deleting one of the currently loaded segments. It introduces overhead by moving data back to the swap disk or relocating it in memory, either of which reduces system performance.
- What is Market Segmentation?
- What is a segmentation fault in C/C++?
- What is a segmentation fault in C/C++ program?
- What is segmentation with respect to text data in Tensorflow?
- Is segmentation fault actual undefined behavior in C++?
- Difference between Paging and Segmentation
- Difference between Demand Paging and Segmentation
- Core Dump (Segmentation fault) in C/C++
- Difference Between Paging and Segmentation in OS
- How can data mining improve market segmentation?
- Overlay an image segmentation with Numpy and Matplotlib
- List of Common Reasons for Segmentation Faults in C/C++
- How to find Segmentation Error in C & C++ ? (Using GDB)
- What is Java API and what is its use?
- What is DatabaseMetaData in JDBC? What is its significance?