Segmentation is a memory management technique whereby data items are stored in segments on the storage media. It divides the process or user-accessible space into fixed-sized blocks, called segments.
Memory management is the process of allocating and controlling the virtual address spaces of computers. It also allows different parts of the kernel to run in separate address spaces.
Segmentation is a memory management technique which divides the program from the user’s view of memory. That means the program is divided into modules/segments, unlike paging in which the program was divided into different pages, and those pages may or may not be loaded into the memory simultaneously. Segmentation prevents internal fragmentation.
A physical address is an address for finding data in the main memory. So now the CPU will take the help of the segment table. A segment table is a data structure for storing the information of all process segments. CPU use a segment table to map the logical address to a physical address. In the segment table, there are two types of information
- Limit: Actual size of a segment.
- Base Address: the address of the segment in the main memory.
Then if the value of offset(d)<=Limit. Then only the CPU can read that segment; else, the error will be there. Offset(d) depicts the size of that segment CPU wants to read.
Advantages of using segmentation technique
- It can improve the system’s efficiency by allowing different kernel parts to run on separate processor cores.
- It can also improve the system’s responsiveness by allowing different threads to run in parallel.
- Provide a solution to internal fragmentation.
- The segment table is there for storing records of segments. This segment table also consumes some memory to get stored.
- Segmentation is near to the user’s view of physical memory. Segmentation allows users to partition the user programs into modules. These modules are nothing but the independent codes of the current process.