内存管理——段式管理
来源:互联网 发布:淘宝定位在哪 编辑:程序博客网 时间:2024/05/01 03:11
本文直接从mit6.828课程参考文献中copy,描述了段式内存管理
5.1 Segment Translation
Figure 5-2 shows in more detail how the processor converts a logical address into a linear address.To perform this translation, the processor uses the following data structures:
- Descriptors
- Descriptor tables
- Selectors
- Segment Registers
5.1.1 Descriptors
The segment descriptor provides the processor with the data it needs to map a logical address into a linear address. Descriptors are created by compilers, linkers, loaders, or the operating system, not by applications programmers. Figure 5-3 illustrates the two general descriptor formats. All types of segment descriptors take one of these formats. Segment-descriptor fields are:BASE: Defines the location of the segment within the 4 gigabyte linear address space. The processor concatenates the three fragments of the base address to form a single 32-bit value.
LIMIT: Defines the size of the segment. When the processor concatenates the two parts of the limit field, a 20-bit value results. The processor interprets the limit field in one of two ways, depending on the setting of the granularity bit:
- In units of one byte, to define a limit of up to 1 megabyte.
- In units of 4 Kilobytes, to define a limit of up to 4 gigabytes. The limit is shifted left by 12 bits when loaded, and low-order one-bits are inserted.
TYPE: Distinguishes between various kinds of descriptors.
DPL (Descriptor Privilege Level): Used by the protection mechanism (refer to Chapter 6 ) .
Segment-Present bit: If this bit is zero, the descriptor is not valid for use in address transformation; the processor will signal an exception when a selector for the descriptor is loaded into a segment register. Figure 5-4 shows the format of a descriptor when the present-bit is zero. The operating system is free to use the locations marked AVAILABLE. Operating systems that implement segment-based virtual memory clear the present bit in either of these cases:
- When the linear space spanned by the segment is not mapped by the paging mechanism.
- When the segment is not present in memory.
Creation and maintenance of descriptors is the responsibility of systems software, usually requiring the cooperation of compilers, program loaders or system builders, and therating system.
5.1.2 Descriptor Tables
Segment descriptors are stored in either of two kinds of descriptor table:- The global descriptor table (GDT)
- A local descriptor table (LDT)
The processor locates the GDT and the current LDT in memory by means of the GDTR and LDTR registers. These registers store the base addresses of the tables in the linear address space and store the segment limits. The instructions LGDT and SGDT give access to the GDTR; the instructions LLDT and SLDT give access to the LDTR.
5.1.3 Selectors
The selector portion of a logical address identifies a descriptor by specifying a descriptor table and indexing a descriptor within that table. Selectors may be visible to applications programs as a field within a pointer variable, but the values of selectors are usually assigned (fixed up) by linkers or linking loaders. Figure 5-6 shows the format of a selector.Index: Selects one of 8192 descriptors in a descriptor table. The processor simply multiplies this index value by 8 (the length of a descriptor), and adds the result to the base address of the descriptor table in order to access the appropriate segment descriptor in the table.
Table Indicator: Specifies to which descriptor table the selector refers. A zero indicates the GDT; a one indicates the current LDT.
Requested Privilege Level: Used by the protection mechanism. (Refer to Chapter 6)
Because the first entry of the GDT is not used by the processor, a selector that has an index of zero and a table indicator of zero (i.e., a selector that points to the first entry of the GDT), can be used as a null selector. The processor does not cause an exception when a segment register (other than CS or SS) is loaded with a null selector. It will, however, cause an exception when the segment register is used to access memory. This feature is useful for initializing unused segment registers so as to trap accidental references.
5.1.4 Segment Registers
The 80386 stores information from descriptors in segment registers, thereby avoiding the need to consult a descriptor table every time it accesses memory.Every segment register has a "visible" portion and an "invisible" portion, as Figure 5-7 illustrates. The visible portions of these segment address registers are manipulated by programs as if they were simply 16-bit registers. The invisible portions are manipulated by the processor.
The operations that load these registers are normal program instructions (previously described in Chapter 3). These instructions are of two classes:
- Direct load instructions; for example, MOV, POP, LDS, LSS, LGS, LFS. These instructions explicitly reference the segment registers.
- Implied load instructions; for example, far CALL and JMP. These instructions implicitly reference the CS register, and load it with a new value.
Because most instructions refer to data in segments whose selectors have already been loaded into segment registers, the processor can add the segment-relative offset supplied by the instruction to the segment base address with no additional overhead.
- 内存管理——段式管理
- 内存管理—页式管理/段式管理/段页式管理
- 操作系统——分段式内存管理
- 操作系统内存管理——分区、页式、段式管理
- 操作系统内存管理——分区、页式、段式管理
- 操作系统内存管理——分区、页式、段式管理
- 操作系统内存管理——分区、页式、段式、段页式管理
- 操作系统内存管理——分区、页式、段式管理
- 操作系统内存管理——分区、页式、段式管理
- 操作系统内存管理——分区、页式、段式管理
- 操作系统内存管理——分区、页式、段式管理
- 操作系统内存管理——分区、页式、段式管理
- 操作系统内存管理——分区、页式、段式管理
- 操作系统内存管理——分区、页式、段式管理
- 操作系统内存管理——分区、页式、段式管理
- 操作系统内存管理——分区、页式、段式管理
- 操作系统内存管理——分区、页式、段式管理
- 操作系统内存管理——分区、页式、段式管理
- 摄影爱好者玩编程:利用Python和OpenCV打造专业级长时曝光摄影图
- 01-Spring-ioc理解
- 刚加入阿里巴巴的施尧耘,想在五年内建起量子计算的体系结构
- 掌柜大作战(6):Spring+Mybatis+多数据源配置+事务配置
- Android编程权威指南笔记
- 内存管理——段式管理
- Sundar Pichai 和他的谷歌进化论
- # 比较filter,map,reduce
- 02-Spring-spring ioc注入的三种方式
- 获香港证监会颁发牌照的弘量研究,正用智能投顾帮助金融机构降低成本,提升资产管理能力
- 03-Spring-ioc工厂bean深入理解
- 深度好奇提出文档解析框架: 面向对象的神经规划
- 平面内直角坐标系中坐标旋转变换公式
- redis实现分布式锁