如何保证物理内存的对齐? [英] How is the alignment of the physical memory guaranteed?

查看:83
本文介绍了如何保证物理内存的对齐?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

malloc()返回适合任何内置类型的内存.如果需要更具体的对齐方式(例如16或32字节),则可以在应用程序级别完成.但是这种对齐是在虚拟内存级别上进行的.

malloc() returns a memory suitably aligned for any in-built type. In cases where more specific alignment is required (like 16 or 32 bytes) it can be done at the application level. But this alignment is at the virtual memory level.

如何保证底层物理内存也处于同一对齐状态?

How is it guaranteed that the underlying physical memory is also at the same alignment ?

推荐答案

虚拟内存是在页面级别实现的,因此每个VM页面在加载到内存时都映射到物理内存页面.因此,比页面更细粒度的所有内容也将在虚拟内存和物理内存之间等效地对齐.

Virtual memory is implemented at the page level, so every VM page maps to a physical memory page when it's loaded into memory. So everything more finely grained than the page will also be aligned equivalently between virtual and physical memory.

这篇关于如何保证物理内存的对齐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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