Segment Descriptor1
Segment Descriptor1
Segment Descriptor
• Segments are areas of memory defined by a
programmer and can be a code, data or stack segment.
• In 80386 segments need not be all the same size and
aligned. And segments need not be exactly 64 KB long,
but we can define them to be any length from 1 byte to
4 GB.
• In 80386 memory segmentation, it is not possible to use
a 16-bit segment register to represent all the
information related to segment. When multiple privilege
levels and intertask protection are required a special
structure called a segment descriptor is used.
Segment Descriptor
• The description of a segment includes its base
address, length, type, privilege level and some
security information.
• The lower base address is specified in bits 16
to 39 and upper 8 bits are specified in bits 56
to 63.
• The lower 16 bits of segments limit are
specified in 0-15 and the remaining 4 bits are
specified in 48-51.
Types of segment descriptors
Non System Segment descriptors
• Defines data, code, stack segments.
• Used by both system and application
programs.
• S=1 in access right byte.
Descriptors
Bit Position Name Function
7 Present (P) P=1 Segment is mapped into physical memory
P=0 No mapping to physical memory exists, base and limit
are not used
6-5 Descriptor Privilege Segment privilege attribute used in privilege tests
Level (DPL)
4 Segment Descriptor S=1 Code or Data segment descriptor
Type (S) S=0 System segment Descriptor or Gate Descriptor
3 Executable(E) E=0 Data segment descriptor type is :
2 Expansion ED=0 Expand Up segment
Direction(ED) ED=1 Expand Down segment
1 Writeable(W) W= 0 Data segment may not be written into
W= 1 Data segment may be written into
3 Executable(E) E=1 Code segment descriptor type is:
2 Conforming(C) C=1 Code segment may only be executed
When CPL DPL and CPL remains
unchanged
1 Readable(R) R=0 Code segment may not be read
R=1 Code segment may be read
0 Accessed(A) A=0 Segment has not been accessed
A=1 Segment selector has been loaded into segment
register or used by selector test instruction
Non System Segment descriptors
• P bit indicates whether segment is present in
memory or not. P = 0 -> Segment is not
present and P = 1-> Segment is present.
LIMIT 20-bit number Offset of last byte in segment from the base
LDT descriptor (s=0, Type 2)
LDT descriptor (s=0, Type 2)
• The LDT descriptors are present in the GDT.
They contain the information about the LDT.
• LDT contains the segment descriptors that are
unique to a particular task.
• The DPL field of the descriptor is ignored as this
descriptor can only be accessed with a privilege
level of 0.
• Here type field =2 i.e. it specifies a LDT
descriptor.
TSS (Task State Segment) Descriptors (s=0,
Type 1, 3, 9 and B)
• Whenever a computer is performing more than one
tasks at a time it may also switch between these
tasks.
• The task may be a single program or a group of
program.
• When one task switches to another task , it stores
all the necessary information required to restart the
task where it was left. This information is called as
the “ state of the task”
• For storing the state of the task the 80386
processor uses a special segment called the “Task
State Segment (TSS)”
TSS (Task State Segment) Descriptors (s=0,
Type 1, 3, 9 and B)
• The task segment is addressed with the help
of TSS descriptor. It contains information
about the location, size and privilege level of a
TSS.
• A TSS descriptor appears only in GDT and not
in IDT or LDT.
• The TSS consists the linkage field for the nest
task that permits the nesting of the tasks.
TSS (Task State Segment) Descriptors (s=0,
Type 1, 3, 9 and B)