简体   繁体   中英

How is the alignment of the physical memory guaranteed?

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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM