Segmentation is a non-contiguous memory management technique. Here the program is divided into variable size parts called segments. So far, we have read about paging, which supports the operating system view of memory. Paging divides the secondary memory into fixed-size partition called pages. Whereas segmentation is a variable size partitioning technique that supports the user’s view of memory. As a user, we view the process as consisting of functions or modules. Therefore in segmentation, the system divides the memory requirement of a process into modules. The modules may be allocated to different locations inside the memory. But, all the addresses of one particular module are together.
A segment is a logical unit such as the main program, function, stacks, common blocks, symbol table etc.
As shown in the figure above, the process consists of four segments. So, the segments can be given different memory location. But, the addresses of one particular segment are together.
The logical address space is a collection of segments. Each segment has a
Name specifies the segment name. For example S1 or Segment 1. The length tells the total number of addresses in the segment.
The address specifies both the segment name and the offset within the segment. Thus, a logical address consists of two things
1. segment number
The syntax of writing a logical address is as shown below
For example, <2,100> means the segment number is 2 while the offset is 100.
Hardware Support using Segment Table
For every process, the system maintains a segment table. This segment table is used to map the logical address into a physical address. Each entry in the segment table has a segment base and segment limit. The segment base contains the starting physical address while the segment limit specifies the length of the segment.
Calculate the physical address for each of logical address given below in the form of <segment number, offset>
the base address of segment number 0 is 200. The vale of limit is 500. Thus, the address space of segment 0 is lies between 200 to 700. Hence, the physical address will be 200+400= 600.
the base address of segment number 1 is 2300. The value of limit is 20. Thus, the address space of segment 1 lies between 2300 to 2320. Hence, the physical address after the calculation is 2300+21= 2321. But, this will generate a trap because the address is going beyond the limit.
For the given segment table, calculate the physical address if the logical addresses are
Share your answers in the comments section
PPT on Segmentation
Note: Clicking on the “next” slide button will not display any animation. Hence, Click within the slide area for animations.
Video on Segmentation
Previous Next Paging Virtual Memory