虚拟内存和调整 - 他们如何共同因素? [英] Virtual memory and alignment - how do they factor together?

查看:227
本文介绍了虚拟内存和调整 - 他们如何共同因素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我明白内存对齐,但什么混淆我的是一个指针在某些系统上的地址将是在虚拟内存中,对不对?所以大部分的检查中/确保对准我看到似乎只是使用指针地址。是没可能的物理内存地址不会被对齐?这难道不是问题的,像SSE?

I think I understand memory alignment, but what confuses me is that the address of a pointer on some systems is going to be in virtual memory, right? So most of the checking/ensuring of alignment I have seen seem to just use the pointer address. Is it not possible that the physical memory address will not be aligned? Isn't that problematic for things like SSE?

推荐答案

物理地址将被对齐,因为虚拟内存只是映射对齐页面的物理内存(和页面通常是4KB)。

The physical address will be aligned because virtual memory only maps aligned pages to physical memory (and the pages are typically 4KB).

所以,除非你需要对齐>页面大小,物理内存会被排列按您的要求。

So unless you need alignment > page size, the physical memory will be aligned as per your requirements.

在上证所的特定情况下,一切工作正常,因为你只需要16字节对齐。

In the specific case of SSE, everything works fine because you only need 16 byte alignment.

这篇关于虚拟内存和调整 - 他们如何共同因素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆