关于IA32体系结构计算机的内存空间问题

http://qdsunny.spaces.live.com/Blog/cns!1pvob8nmBwGJD_1gk2FNtnLQ!161.entry

in kHTTPd:

get_fs();

set_fs(KERNEL_DS);

sock_sendmsg(......);

[@more@]
关于IA32体系结构计算机的内存空间问题

32位体系结构的计算机到底寻址空间是多少?2^32=4G啊!对!
没错,但是Intel从Pentium Pro处理器起,CPU就拥有了36根地址
线,同时在CPU内部增加了PAE寄存器。用于记录多出来的4根地址
线的使用情况,所以,2^36=64G,并通过一种叫做PAE的技术实现
最大64G寻址,当然,能否用到64G还取决于使用的操作系统,比如:
Windows 2000 professional就只能使用4G内存,看来在编译时没
有启用PAE支持。看起来不错的样子,但是OS能用,并不表示用户
程序能用,Windows怎么处理的我们不得而知,下面的文章来自:
http://www.kerneltrap.org/node/2450
介绍了Linux的处理方法,我想Windows也应该类似:

Overview of Linux memory management
32-bit architectures can reference 4 GB of physical memory
(2^32). Processors that have an MMU (Memory Management Unit) support
the concept of virtual memory: page tables are set up by the kernel
which map "virtual addresses" to "physical addresses"; this basically
means that each process can access 4 GB of memory, thinking it's the
only process running on the machine (much like multi-tasking, in which
each process is made to think that it's the only process executing on
a CPU).

The virtual address to physical address mappings are done by the
kernel. When a new process is "fork()"ed, the kernel creates a new set
of page tables for the process. The addresses referenced within a
process in user-space are virtual addresses. They do not necessarily
map directly to the same physical address. The virtual address is
passed to the MMU (Memory Management Unit of the processor) which
converts it to the proper physical address based on the tables set up
by the kernel. Hence, two processes can refer to memory address
0x08329, but they would refer to two different locations in
memory.

The Linux kernel splits the 4 GB virtual address space of a process in
two parts: 3 GB and 1 GB. The lower 3 GB of the process virtual
address space is accessible as the user-space virtual addresses and the
upper 1 GB space is reserved for the kernel virtual addresses. This is
true for all processes.
The kernel virtual area (3 - 4 GB address space) maps to the first 1
GB of physical RAM. The 3 GB addressable RAM available to each process
is mapped to the available physical RAM
......
HIGHMEM solution for using 64 GB of memory
This is enabled via the PAE (Physical Address Extension) extension
of the PentiumPro processors. PAE addresses the 4 GB physical memory
limitation and is seen as Intel's answer to AMD 64-bit and AMD
x86-64. PAE allows processors to access physical memory up to 64 GB
(36 bits of address bus). However, since the virtual address space is
just 32 bits wide, each process can't grow beyond 4 GB. The mechanism
used to access memory from 4 GB to 64 GB is essentially the same as
that of accessing the 1 GB - 4 GB RAM via the HIGHMEM solution
discussed above.

可见,标准Linux内核对于物理内存的管理采用1:3的分配比例,即物理内存的
1/4为内核空间(kernel space),剩下的3/4为用户进程空间(user space),
因此,在一台4G内存的服务器上,用户进程可使用的内存最大也就是3G。当进程
被内核调入CPU运行时,相应的PAE寄存器也会被调入,即使它和别的进程都访问
0x08344的地址,但由于PAE寄存器不同,不同的地址空间数据会被调入4G以内的
标准用户进程空间(实际上也就是3G),这被称为PAE内存映射技术。

采用什么技术映射内存并不重要,那是内核技术,但必须知道的是:
IA32架构上,单一进程是不能使用超过4G的内存空间的。换言之,如果我们的
服务器运行的服务不是以多进程方式运行,那么大于4G的内存将变得毫无意义。
实际上,由于4G的寻址空间中会有部分属于内核空间,因此用户空间,即用户
程序进程能使用的空间肯定要小于4G。这一点已被一些程序证实,比如Sybase
11.0.3,在一台2C4G的服务器上,运行Windows 2000 Server,支持最大64G内
存,调优数据库时,无论怎么调整参数,数据库引擎使用的内存数量不会超过
1.7G(两颗CPU,启动了两个数据库引擎);还有JVM,最好的BEA JRockit在
IA32位架构上,最大也只能使用1.8G内存(bea 建议使用物理内存的75%,并
小于1.8G)。这些数值都远远小于4G。

下面RedHat自己的描述证实了我的理解:
Red Hat Enterprise Linux 3 includes a new kernel known as the hugemem
kernel. This kernel supports a 4GB per process user space (versus 3GB
for the other kernels), and a 4GB direct kernel space. Using this kernel
allows Red Hat Enterprise Linux to run on systems with up to 64GB of main
memory. The hugemem kernel is required in order to use all the memory in
system configurations containing more than 16GB of memory.
If you have over 16G memory, this works, but the max for single process
is still 4G
. Other kernels only support 3G per process.
嗯,RHEL 3 提供了一种被称为hugemem(巨型内存)的内核,可以实现4G内核空间
和4G用户空间,用于实现巨型内存(>16G)支持。但是,单一进程仍然被限制在4G
用户空间以内,而一般的内核,只支持3G用户空间。

总结:IA32位架构计算机的寻址空间取决于以下三方面:
一、采用的CPU和主板(芯片组)-硬件
如果CPU使用PAE技术,并且主板使用了多余的地址线,那么物理寻址空间可以
达到64G。
二、采用的操作系统 - OS
如果操作系统在编译时打开PAE支持或选项,那么OS寻址空间也可以达到理论上
的64G,但由于OS在处理内存时采用的PAE页面调入技术,用户进程的内存数量
将被限制在4G以内,就是32位架构的寻址极限。
三、运行的程序 - 用户进程
很多时候,为了使自己的软件运行稳定,软件厂商会跟据情况,调整自己程序的
内存分配或申请策略。因而,用户进程的内存使用还会受到应用程序的限制。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/69498/viewspace-925950/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/69498/viewspace-925950/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值