Segment Descriptor


In an operating system, segmentation is termed a memory management technique where the memory is divided into segments that can be allocated to a process. These segments may not be in fixed length and not stored in a contagious manner. This approach has been developed after the paging process which takes multiple pages for a process to get loaded into main memory, whereas segmentation divided the code into segments as its relative code can be merged to form a single block.

The segment table holds all the details relating to the segments and the processes. Generating a logical address which is converted to a physical address by the CPU by refereeing to the segment table. This table contains two fields about the segments and they are base and limit. Base or segment base denotes the base address of the segment which holds the initial physical address of segments and limit denotes the length of the segment. Segmentation can be classified as virtual segmentation and simple segmentation, depending on how the processes are divided into segments and locating them in the memory area.

Segment Descriptor

Segment Descriptor is used in the segmentation process to translate a logical address to a linear address. The memory segments that are divided have attributes of privilege, initial or base address, segment limit, and usage. All this information is stored in a segment descriptor. They contain global and local descriptor tables that are identified using segment selectors.

The segment descriptor has 8 bytes long structure with a 32-bit base address and 20 bits of limit and access rights in 80286 architecture and later, and the following fields of the system descriptor are listed below −

  • Segment’s base address.

  • Segment limit denotes the segment size

  • Access rights byte which represents the user protection mechanism for accessing the information.

  • Control bits of the segments

Structure of segment descriptor

The diagram above represents the structure of the format of segment descriptors and listed below are the fields or components present inside them.

  • Segment base address − This consists of a 32-bit base address of the segment in the linear address space. It is in the lower part ranging from 16 to 31 and the upper part from 0 to 7 then with bits 24 to 31.

  • Segment Limit − It defines the 20-bit field which is the largest offset and it can be interpreted based on the granularity bit either G=0 or 1.

  • Granularity − This indicates the limit is a byte with G=0 or a page with 4 Kilobytes if G=1. Limit supports up to 220 bytes and for pages, it is 4096 bytes, with maximum 232 bytes

  • Default − This field represents the default size of the operand. It depicts the segment as either 32-bit or 64-bit with D=0 and D=1 values.

  • Big − It is used for data segments with a maximum offset 32 bit 0xffffffff when a bit is set to 1 and 0x0000ffff for 16-bit.

  • Long − It is used for 64-bit segments with instruction encoding and the D field should be 0 when L is set to 1.

  • Available/User bit − It is available for the user and ignored by the x86, intended for software use, and not defined by the hardware

  • Present Bit − When it is set to 1, the current segment of the process is loaded into the memory, when the field is 0 then accessing it will cause a not found exception

  • Descriptor level privilege − It represents the segment’s privilege level given by numbers 0,1,2, and 3 where Level 0 (data field as 00) is the most privileged level with kernel part, the supervisor can access it, level 1 (01), level 2 (10) and level 3 (11) has the least privilege given to the user

  • System Bit − When S is 1, it represents code or data segment if S is 0 then it means segment or gate descriptor.

  • Type − It has several types with access permissions such as: Readable with R=1 or R=0, indicates whether the segment is in readable mode or not.

    Writable with W=1 or W=0, indicates whether the segment is in writable mode or only for reading.

    Conforming with C=1 or C=0, invoked from fewer privilege levels for code segments

    Accessed Bit with A=0 or A=1, indicates the segment is not accessed or it has been loaded into the register.

Conclusion

Segmentation technique is used for dividing the processes into smaller modules called segments and relative data are combined to form a single segment to load into the memory. The size of partitioning the modules depends on the length and type of the input processes. Segment tables are maintained to store information about the segments and their tasks. The segment descriptor and the global descriptor table are used by the CPU to retrieve information regarding the segment type and its memory. This process offers maximum utilization of CPU as the similar data of segments are loaded at the same time as one segment.

Updated on: 18-Jul-2023

246 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements