本文介绍了使用额外的16位在64位机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读了一个64位的机器实际使用的只有48位(具体而言,我使用英特尔I7)。Why做64位系统只有一个48位的地址空间?

I read that a 64 bit machine actually uses only 48 bit (specifically, I'm using intel i7).Why do 64 bit systems have only a 48 bit address space?

我期望额外的16位(位48-63)是不相关的地址,并且将被忽略。但是,当我尝试访问这样的地址,我得到了一个信号EXC_BAD_ACCESS。我的code是:

I would expect that the extra 16 bits (bits 48-63) are irrelevant for the address, and would be ignored.But, when I try to access such an address, I got a signal EXC_BAD_ACCESS.My code is:

int *p1 = &val;
int *p2 = (int *)((long)p1 | 1ll<<48);//set bit 48, which should be irrelevant
int v = *p2; //Here I receive a signal EXC_BAD_ACCESS.

为什么会是这样?有没有一种方法来使用这16位?

Why this is so?Is there a way to use these 16 bits?

这可以用来建设更多的高速缓存友好的链接列表。代替使用8个字节下一个PTR,和8个字节的键(由于取向限制)的,键可以被嵌入到指针。

This could be used to build more cache friendly link list. Instead of using 8 bytes for next ptr, and 8 bytes for key (due to alignment restriction), the key could be embedded into the pointer.

感谢

推荐答案

据英特尔手册(第1卷,第3.3.7.1)线性地址必须是在规范形式。这意味着,实际上只有48位的使用和额外的16位的位扩展。此外,实施需要检查的地址是否是在这种形式,如果它不产生异常。这就是为什么没有办法使用这些额外的16位。

According to the Intel Manuals (volume 1, section 3.3.7.1) linear addresses has to be in the canonical form. This means that indeed only 48 bits are used and the extra 16 bit are bit extended. Moreover, the implementation is required to check whether an address is in that form and if it is not generate an exception. That's why there is no way to use those additional 16 bits.

之所以它是以这样的方式进行相当简单。目前48位虚拟地址空间是绰绰有余(和由于在CPU生产成本有在使其较大无点),但毫无疑问在未来的附加位将是必要的。如果应用程序/内核要使用他们自己的目的兼容性问题会出现,这就是CPU厂商希望避免的。

The reason why it is done in such way is quite simple. Currently 48 bit virtual address space is more than enough (and because of the CPU production cost there is no point in making it larger) but undoubtedly in the future the additional bits will be needed. If applications/kernels were to use them for their own purposes compatibility problems will arise and that's what CPU vendors want to avoid.

这篇关于使用额外的16位在64位机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 19:24