Normal
0
false
false
false
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
图3-2 虚拟地址转换成物理地址的过程
从图3-2中可以看出,当CPU访问某虚存地址时,不管是读指令或读写数据,该地址首先会被发送给内存管理单元进行转换。在获得转换后的物理地址后,CPU再对该物理地址进行读写操作。
为什么要单独增加一个MMU硬件来处理虚拟地址向物理地址的转换呢?...
Normal
0
false
false
false
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
3.2 虚拟内存的优点
3.2.1 安全性
虚拟内存是保证系统安全的一个重要机制。
Normal
0
false
false
false
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
Normal
0
false
false
false
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
Normal
0
false
false
false
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
3.2.2 提高空间利用率
利用虚存机制还可以充分利用物理内存空间
Normal
0
false
false
false
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
3.2.3 多进程的支持
Normal
0
false
false
false
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
3.3 PDP11/40的虚拟内存机制
PDP 11/40的内存管理单元把物理内存等分成很多大小为64字节的连续块(block),并从0开始顺序编号,如图3-7所示:
尽管PDP 11/40的操作模式都是16位模式,但它的CPU和总线都支持18位地址模式,所以其最大地址空间实际可达256K,4096个物理块。
PDP 11/40的内存管理单元为用户模式和内核模式分别提供了8组、每组两个内存映射寄存器:
8个16位页地址寄存器PAR(Page Address Register):PAR0~7
8个16位页描述寄存器 PDR(Page Descriptor Register):PDR0~7
这样,实际上系统中一共有8×2×2=32个内存映射寄存器。每对PAR/PDR可称为一个
32位的APR(活动页寄存器——Active Page Register),APR在物理上并不存在,它是为了理解和叙述上的方便而引入的。活动页寄存器示意图如图3-8所示。
Normal
0
false
false
false
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
内存管理单元对虚拟内存按页管理,它把虚拟内存分成很多活动页,每一个活动页最大不超过8K,由一个32位的活动页寄存器来描述它映射到物理内存的情况。因此64K的虚拟内存需要8个活动页寄存器才能完成映射。虚拟内存与活动页寄存器对应的情况如图3-9 所示。
Normal
0
false
false
false
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
图3-9 虚拟内存与活动页寄存器对应图
3.3.1 页地址寄存器(PAR)
Normal
0
false
false
false
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
页地址寄存器是32位活动页寄存器的第一个字(word),其位11~0共12位是页地址字段PAF(Page Address Field),用于指定物理内存的块号,并以该块地址作为本虚拟页的起始地址。例如:PAF
= 100,则本虚拟页从100号物理块开始,起始物理地址是100 × 64 = 6400=0x1900。
Normal
0
false
false
false
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
位15~12保留未使用。
3.3.2 页描述寄存器(PDR)
Normal
0
false
false
false
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
页描述寄存器是32位活动页寄存器的第二个字,它用来描述本页的一些属性,比如访问权限和大小等。
(1)位2~1:访问控制字段(Access Control Field),用于设定页的访问权限。
Normal
0
false
false
false
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
值
|
模 式
|
备 注
|
00
|
不存在
|
任何形式的访问都会导致异常退出
|
01
|
只读
|
只允许读操作,写操作会导致异常退出
|
10
|
未使用
|
任何形式的访问都会导致异常退出
|
11
|
读写
|
读写操作都允许
|
如果程序指令对页实行非该字段允许的操作,则会导致产生自陷而退出(abort)。
(2)位3:方向延续字段(Expansion Direction),该字段指定页内存空间的延续方向。
ED=0:空间向上延续(upwards)。页地址寄存器中的PAF字段指定的物理块是该页的最低地址块,并且地址空间向高地址延续。
ED=1:空间向下延续(downwards)。页地址寄存器中的PAF字段指定的物理块并不是该页的最低地址块,而是它的一个基线,地址空间从PAF+128处向低地址延续。
(3)6:修改标志位(Written
Info)。表示该页是否被修改过。这和现代虚拟内存页中的脏页标志(dirty
flag)非常相似。主要用于指导在进程换出操作时,该页是否需要被换出。如果该位被置(W=1),表明该页在程序运行期间被修改过,则需要换出(写入磁盘)以防数据丢失,否则该页不需要换出。但UNIX系统在进行换出操作时,并没有判断该位,即不管该页是否被修改都换出。
... ...
上一章 UNIX综述 目录 下一章 启动过程
本书在全国各大书店及网城均有销售: