- Segmentation is a memory management technique in which process is dividing into the segments and the segments are of variable size.
- The details about each segment are stored in a table called a segment table. Segment table is stores mainly two information of the segments.
- Base: It is the base address of the segment
- Limit: It is the length of the segment
Why we need segmentation ?
- Paging is our main memory management technique. Paging is more close to the Operating system . It divides all the processes into the form of pages regardless of the fact that a process can have some relative parts of functions which need to be loaded in the same page. It not provide user view of the process. about the User’s view of the process. divide the function into different pages and not be loaded at the same time into the memory. It decreases the efficiency of the system.
- On the other hand segmentation which divides the process into the segments. Each segment contains the same type of functions such as the main function can be included in one segment and the library functions can be included in the other segment.

Address Translation
In segmentation , the mapping of logical address to physical address is provided by using a segment table contained in memory management unit. The CPU generates a logical address which contains two parts.
1. Segment Number
2. Offset

The Segment number Map with the Segment table and the limit of segment is compared with offset , If it is less than limit than the address is valid otherwise it generates an error.
If the address is valid the base address of the segment is added to the offset To get physical address in the memory.

Advantages of Segmentation
- No internal fragmentation.
- Average Segment Size is larger than the actual page size.
- The use of protection bits prevents illegal access to the memory locations. In this way, an attempt to write to a read-only segment fails.
- The sharing of code or data is possible even in segmentation
Disadvantages of Segmentation
- As with paging, this mapping also requires two memory references per logical address. This slows down a system by a factor of 2.
- Segmentation suffers from external fragmentation. This may occurs when all the blocks in the memory are too small to accommodate segment. Compaction, if possible, may sometimes be applied to solve this problem.
- Considerable compaction overhead is incurred in order to support dynamic segment growth.
- Increase in the number of segments in memory increases the size of a segment table. As a result of this, segment table cannot be kept in any registers.
- Another disadvantage of segmentation is that the programmer must be aware of the maximum size limits of the segments.
- It is also very difficult to manage variable size segments on secondary storage.
- The maximum size of a segment is limited by the size of main memory.