Chinaunix首页 | 论坛 | 博客
  • 博客访问: 56273
  • 博文数量: 47
  • 博客积分: 2095
  • 博客等级: 大尉
  • 技术积分: 560
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-01 18:42
文章分类

全部博文(47)

文章存档

2011年(1)

2008年(46)

我的朋友

分类: LINUX

2008-04-01 19:15:22

Segment Descriptors
Each segment is represented by an 8-byte Segment Descriptor that describes the segment characteristics. Segment Descriptors are stored either in the Global Descriptor Table (GDT ) or in the Local Descriptor Table(LDT).
 
每个段由一个8byte的段描述符来描述其特征。每个段描述存放在GDT(全局描述表)或者LDT(局部描述表)中。
 
Usually only one GDT is defined, while each process is permitted to have its own LDT if it needs to create additional segments besides those stored in the GDT. The address and size of the GDT in main memory are contained in the gdtr control register, while the address and size of the currently used LDT are contained in the ldtr control register.
 
通常只定义一个GDT,而每个进程如果需要创建额外的段,允许拥有自己的LDT。主存中GDT的地址(这里是线形地址)和大小存储在gdtr控制寄存器中,相应地,当前使用的LDT的地址和大小存放在ldtr控制寄存器中。
 
Figure 2-3 illustrates the format of a Segment Descriptor; the meaning of the various fields is explained in Table 2-1.
Table 2-1. Segment Descriptor fields

Field name
Description
Base
Contains the linear address of the first byte of the segment.
该段第一个byte线性地址
G
Granularity flag: if it is cleared (equal to 0), the segment size is expressed in bytes; otherwise, it is expressed in multiples of 4096 bytes.
粒度,如果值为0,段大小单位用bytes表示,否则用4KB表示
Limit
Holds the offset of the last memory cell in the segment, thus binding the segment length. When G is set to 0, the size of a segment may vary between 1 byte and 1 MB; otherwise, it may vary between 4 KB and 4 GB.
表示段中最后一个内存单元的偏移,即段长度。当G=0时,段大小在1byte到1MB之间;否则,在4KB到4GB之间
S
System flag: if it is cleared, the segment is a system segment that stores critical data structures such as the Local Descriptor Table; otherwise, it is a normal code or data segment.
系统标志:s=0表示系统段,存储关键数据结构比如LDT;s=1表示普通代码或数据段。
Type
Characterizes the segment type and its access rights (see the text that follows this table).
段类型和访问权限
DPL
Descriptor Privilege Level: used to restrict accesses to the segment. It represents the minimal CPU privilege level requested for accessing the segment. Therefore, a segment with its DPL set to 0 is accessible only when the CPL is 0 that is, in Kernel Mode while a segment with its DPL set to 3 is accessible with every CPL value.
描述权限:用来限制对段的访问。它规定了访问该段要达到的最小权限。
P
Segment-Present flag : is equal to 0 if the segment is not stored currently in main memory. Linux always sets this flag (bit 47) to 1, because it never swaps out whole segments to disk.
段存在标志:0不在内存。Linux总是设置该标志为1.
D or B
Called D or B depending on whether the segment contains code or data. Its meaning is slightly different in the two cases, but it is basically set (equal to 1) if the addresses used as segment offsets are 32 bits long, and it is cleared if they are 16 bits long (see the Intel manual for further details).
AVL
May be used by the operating system, but it is ignored by Linux.

There are several types of segments, and thus several types of Segment Descriptors. The following list shows the types that are widely used in Linux.
 
因为有不同类型的段,所以就有不同类型的段描述。下面列出了Linux广泛使用的类型:
 
Code Segment Descriptor
Indicates that the Segment Descriptor refers to a code segment; it may be included either in the GDT or in the LDT. The descriptor has the S flag set (non-system segment).
代码段描述
     可在GDT/LDT中,s=1。
 
Data Segment Descriptor
Indicates that the Segment Descriptor refers to a data segment; it may be included either in the GDT or in the LDT. The descriptor has the S flag set. Stack segments are implemented by means of generic data segments.
数据段描述
     可在GDT/LDT中,s=1。堆栈段是由一般的数据段实现的。
 
Task State Segment Descriptor (TSSD)
Indicates that the Segment Descriptor refers to a Task State Segment (TSS) that is, a segment used to save the contents of the processor registers (see the section "Task State Segment" in Chapter 3); it can appear only in the GDT. The corresponding Type field has the value 11 or 9, depending on whether the corresponding process is currently executing on a CPU. The S flag of such descriptors is set to 0.
任务状态段描述
任务状态段用来保存处理器寄存器的内容,只会出现在GDT中。对应的type字段值为11或9,取决于对应的进程是否在一个CPU中运行,s字段设为1.
Figure 2-3. Segment Descriptor format
 
Local Descriptor Table Descriptor (LDTD)
Indicates that the Segment Descriptor refers to a segment containing an LDT; it can appear only in the GDT. The corresponding Type field has the value 2. The S flag of such descriptors is set to 0. The next section shows how 80 x 86 processors are able to decide whether a segment descriptor is stored in the GDT or in the LDT of the process.
LDT描述项
     只出现在GDT中,type=2s=0。下面将会讲80x86是如何分辨一个描述是存放在GDT还是在LDT中的。
阅读(425) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~