📄 1142.html
字号:
</SCRIPT>
<BODY text=#000000 bgColor=#ffffff leftMargin=0 topMargin=0 marginwidth="0"
marginheight="0">
<CENTER>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TR>
<TD vAlign=top>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=296
border=0></TD>
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=76
border=0></TD>
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=100
border=0></TD>
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=98
border=0></TD>
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=79
border=0></TD>
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=103
border=0></TD>
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=26
border=0></TD>
<TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=1
border=0></TD></TR>
<TR>
<TD colSpan=3><A title=linux知识宝库
href="index.html" tppabs="http://www.linuxhero.com/docs/index.html"><IMG height=83
src="images/header_r1_c1.gif" tppabs="http://www.linuxhero.com/docs/images/header_r1_c1.gif" width=472 border=0
name=header_r1_c1></A></TD>
<TD colSpan=3>
<form action="http://www.linuxhero.com/docs/search.html" method=get>
<table
style="BORDER-RIGHT: #c4c4c4 1px solid; BORDER-TOP: #c4c4c4 1px solid; BORDER-LEFT: #c4c4c4 1px solid; BORDER-BOTTOM: #c4c4c4 1px solid"
cellspacing=0 cellpadding=3 width="95%" border=0 align="center">
<tbody>
<tr>
<td noWrap background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif">
<div align=center><font class=normalfont>搜索文章:
<input type=hidden value=result name=action2>
<input type=radio checked value=title name=type>标题
<input type=radio value=content name=type>内容
<input type=image src="images/button_go.gif" tppabs="http://www.linuxhero.com/docs/images/button_go.gif" border=0 name=image2>
</font></div>
</td>
</tr>
<tr>
<td noWrap>
<div align="center">
<input maxlength=100 size=30 name=keyword2>
</div>
</td>
</tr></tbody>
</table>
</form>
</TD>
<TD rowSpan=2><IMG src="images/header_r1_c7.gif" tppabs="http://www.linuxhero.com/docs/images/header_r1_c7.gif" width=26 border=0 name=header_r1_c7></TD>
<TD><IMG height=83 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=1 border=0></TD></TR>
<TR>
<TD background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif"><IMG height=22
src="images/header_r2_c1.gif" tppabs="http://www.linuxhero.com/docs/images/header_r2_c1.gif" width=296 border=0
name=header_r2_c1></TD>
<TD background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colSpan=5>
<DIV align=right><FONT class=normalfont>当前位置:
<A href="index.html" tppabs="http://www.linuxhero.com/docs/index.html">本站首页</A>
<font color="#FF6699">>></font>
<A href="type16.html" tppabs="http://www.linuxhero.com/docs/type16.html">内核技术</A> | <A href="copyright.html" tppabs="http://www.linuxhero.com/docs/copyright.html">版权说明</A></font></DIV>
</TD>
<TD><IMG height=22 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=1
border=0></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=10 cellPadding=0 width="100%" bgColor=#ffffff
border=0>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=3 width="100%" border=0>
<TR>
<TD vAlign=top align=middle width="60%">
<TABLE cellSpacing=0 cellPadding=0 width="100%"
background="images/back.gif" tppabs="http://www.linuxhero.com/docs/images/back.gif" border=0>
<TBODY>
<TR>
<TD vAlign=top width="80%">
<DIV align=center>
<FORM action="search.html" tppabs="http://www.linuxhero.com/docs/search.html" method=get>
</FORM>
<TABLE cellSpacing=0 cellPadding=0 width="95%"
border=0><TBODY>
<TR>
<TD background="images/bgi.gif" tppabs="http://www.linuxhero.com/docs/images/bgi.gif"
height=30></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=3 width="95%"
align=center border=0>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=3 width="100%"
border=0>
<TBODY>
<TR>
<TD vAlign=top>
<p><FONT class=normalfont><B><font color=blue>Linux在X86上的虚拟内存管理</font></B></FONT><BR><FONT class=smallfont color=#ff9900>2004-04-23 15:18 pm</FONT><BR><FONT class=normalfont>作者:周梦醒<br>来自:Linux知识宝库<br>联系方式:无名<br><br>前言<br>
Linux支持很多硬件运行平台,常用的有:Intel X86,Alpha,Sparc等。对于不能够通用的一些功能,Linux必须依据硬件平台的特点来具体实现。本文的目的是简要探讨Linux在X86保护模式上如何实现虚拟内存管理功能。为简化和方便叙述,本文做如下限定:X86处理器为80486和其后的处理器,X86工作在保护模式,不采用物理内存扩展(使用32bits物理地址),不使用扩展页(页大小为4K)。凡是与限定模式无关的内容,本文都尽量略过。Linux的虚拟内存管理中与硬件平台无关的内容在本文中也被略过。本文所援引的Linux内核源代码版本为Linux 2.2.5。<br>
<br>
X86的分段和分页机制<br>
<br>
I. X86的分段机制和相应系统结构<br>
X86的分段机制就是将X86的线性地址空间分成许多小空间--段(segment),利用这些段来存储(记录)代码和数据,通过对段的保护来提供一种对数据或代码的保护。根据每个段的作用和存储内容的不同,X86将段分为三类进程段(代码段、数据段和堆栈段)和两类系统段:任务状态段(TSS,Task-State Segment)和LDT段(由于GDT不是通过段描述符和段选择符来访问,所以X86没有认为存在一个GDT段;同理,也不存在IDT段)。<br>
在分段机制,X86使用了如下几种主要数据结构:<br>
· 全局描述符表(GDT,Global Describtor Table):存放系统用的段描述符和各项任务共用的段描述符,可以是上述的任何一类段的段描述符,最大表长64KB;<br>
· 局部描述符表(LDT,Local Describtor Table):存放某个任务专用的各段的段描述符,只能是三类进程段的段描述符和调用门描述符,最大表长4GB;<br>
· 段描述符(Segment Describtor):64bits,用来描述一个段的基地址(该地址是线性地址),该段的类型,对该段操作的限制;<br>
· 门描述符(Gate Describtor):64bits,一种特殊的描述符,为处于不同特权级的系统调用或程序的调用或访问提供保护;分为四类:调用门描述符(Call Gate Describtor)、中断门描述符(Interrupt Gate Describtor)、陷阱门描述符(Trap Gate Describtor)、任务门描述符(Task Gate Describtor);<br>
· 段选择符(Segment Selector):16bits,用于在GDT或LDT中索引相应的段描述符;<br>
· 中断描述表(IDT,Interrupt Describer Table):存放门描述符,只能是中断门描述符,陷阱门描述符和任务门描述符,最大表长64KB;<br>
同时,X86提供了如下几个用于支持分段机制的寄存器:<br>
· 全局描述符表寄存器(GDTR,GDT Register):48bits,32bits为GDT的基地址(线性地址),16bits为GDT的表长;GDTR的初始值为:基地址0,表长0xFFFF;<br>
· 局部描述符表寄存器(LDTR,LDT Register):80bits,16bits为LDT段选择符,64bits为该LDT段的段描述符; <br>
· 中断描述符表寄存器(IDTR,IDT Register):48bits,32bits为IDT的基地址(线性地址),16bits为IDT的表长;IDTR的初始值为:基地址0,表长0xFFFF;<br>
· 任务寄存器(TR,Task Register):80bits,16bits为任务状态段选择符,64bits为该任务状态段的段描述符;<br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -