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

全部博文(47)

文章存档

2011年(1)

2008年(46)

我的朋友

分类: LINUX

2008-04-05 09:39:18

The Linux GDT

In uniprocessor systems there is only one GDT, while in multiprocessor systems there is one GDT for every CPU in the system. All GDTs are stored in the cpu_gdt_table array, while the addresses and sizes of the GDTs (used when initializing the gdtr registers) are stored in the cpu_gdt_descr array. If you look in the Source Code Index, you can see that these symbols are defined in the file arch/i386/kernel/head.S . Every macro, function, and other symbol in this book is listed in the Source Code Index, so you can quickly find it in the source code.

UP系统只有一个GDT,而多处理器系统每个CPU都有一个对应的GDT。所有的GDT都存储在数组cpu_gdt_table里,而GDT的基地址和大小(用来初始化gdtr寄存器)则存放在数组cpu_gdt_descr里。定义在 arch/i386/kernel/head.S中。

The layout of the GDTs is shown schematically in Figure 2-6. Each GDT includes 18 segment descriptors and 14 null, unused, or reserved entries. Unused entries are inserted on purpose so that Segment Descriptors usually accessed together are kept in the same 32-byte line of the hardware cache (see the section "Hardware Cache" later in this chapter).

GDT的层次如图所示。每个GDT18个段描述符和14个空的不用或者保留的记录。不用的记录是有意插进去的,使得经常使用的段描述符放在硬件cache的同一个32byte行。

The 18 segment descriptors included in each GDT point to the following segments:

18个段描述符是:

·         Four user and kernel code and data segments (see previous section).

          四个用户/内核 代码/数据段。

·         A Task State Segment (TSS), different for each processor in the system. The linear address space corresponding to a TSS is a small subset of the linear address space corresponding to the kernel data segment. The Task State Segments are sequentially stored in the init_tss array; in particular, the Base field of the TSS descriptor for the nth CPU points to the nth component of the init_tss array. The G (granularity) flag is cleared, while the Limit field is set to 0xeb, because the TSS segment is 236 bytes long. The Type field is set to 9 or 11 (available 32-bit TSS), and the DPL is set to 0, because processes in User Mode are not allowed to access TSS segments. You will find details on how Linux uses TSSs in the section "Task State Segment" in Chapter 3.

           一个任务状态段TSS,对于每个处理器都不同。对应一个TSS的线形地址空间是对应内核数据段线形空间一个很小的子集。TSS按顺序地存放在init_tss数组中;第nCPUTSS描述符的base字段指向数组init_tss的第n个元素。G字段为0,而limit字段设置为0xEB,因为TSS段有236byte长。Type字段设为911dpl设为0,因为用户模式的进程不允许访问TSS段。

·         A segment including the default Local Descriptor Table (LDT), usually shared by all processes (see the next section).

          一个保护默认LDT的段,通常被所有处理器共享。

·         Three Thread-Local Storage (TLS) segments: this is a mechanism that allows multithreaded applications to make use of up to three segments containing data local to each thread. The set_thread_area( ) and get_thread_area( ) system calls, respectively, create and release a TLS segment for the executing process.

           3TLS:内核有一种机制允许多线程程序利用这三个包含本地数据的段。set_thread_area()get_thread_area()系统调用,分别为一个正在执行的进程创建和释放一个TLS段。

·         Three segments related to Advanced Power Management (APM ): the BIOS code makes use of segments, so when the Linux APM driver invokes BIOS functions to get or set the status of APM devices, it may use custom code and data segments.

          三个与高级电源管理有关的段:BIOS的代码使用这些段。

·         Five segments related to Plug and Play (PnP ) BIOS services. As in the previous case, the BIOS code makes use of segments, so when the Linux PnP driver invokes BIOS functions to detect the resources used by PnP devices, it may use custom code and data segments.

           五个与PnP BIOS服务有关的段

·         A special TSS segment used by the kernel to handle "Double fault " exceptions (see "Exceptions" in Chapter 4).

      一个特殊的TSS段,内核用来处理“Double falt”异常。
阅读(419) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~