Segmentation in Operating System (OS)

Segmentation in Operating System

  • Segmentation is more like, user’s end of memory management scheme.
  • Just like paging, it divides or segments the memory. But, while paging divides memory into fixed size, segmentation divides the memory in variable segments, which are then loaded into logical memory space. There are following types of segmentation –
    • Virtual Memory Segmentation – Each processes is segmented into n divisions, however, they are not segmented all at once.
    • Simple Segmentation – Each processes is segmented into n divisions, they are all together segmented at once exactly at runtime. While, they may be scattered in the memory i.e. can be non contiguous.
Segmentation in OS Operating System

How Segmentation works?

Just like page table or TLB, for segmentation all the information necessary is stored into the segment table. The relationship between the logical and physical address is a bit more complex here.

The unit involved here are –

  • Segment table
  • Base Address
  • Limit
  • Segment Number (s)
  • Segment Offset (d)

Segment Table

The correlation and mapping for the logical address which is 2 dimensional address and the physical address is done with the help of segment table.

Base Address

The starting address of the memory where the data is stored in its logical format in the system.

Say Base address is 8000, then the data will be available in addresses from 8000 onwards.

Limit

Since the size of each segment is different, thus each segment has its own limit defined and it tells the system about the size or length of any particular segment.

Further for mapping to physical form for the CPU the following are required –

  1. Segment Number (s) – It is basically the total number of bits that are required to store any particular address of the segment in consideration
  2. Segment Offset (d) – Number of bits required for the size of the segment.

The process can be easily visualised from the image below-

Segmentation in OS Operating System

Contrast with Paging

Paging

  • Page size is fixed
  • Can lead to internal fragmentation
  • Size is decided by the Hardware
  • Address mapping is simple and page table is sufficient

Segmentation

  • Segment size is variable
  • Can lead to external fragmentation
  • Size is decided by the user
  • Address mapping is complex even with the help of segment table, segment number and offset.

Please Login/Signup to comment