连续的内存和VM块 [英] Contiguous blocks of memory and VM

查看:96
本文介绍了连续的内存和VM块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读虚拟内存,据我了解,每个进程都有自己的VM表,该表将VM地址映射到实际内存中的物理地址.因此,如果进程连续分配对象,则可能会将它们存储在物理内存中完全不同的位置.我的问题是,如果我分配并存储应该存储在连续内存块中的数组,并且如果数组的大小需要的空间超过一页可以提供的空间,那么据我了解,数组将连续存储在VM中但可能在PM中的位置完全不同.这样对吗?如果我误解了VM的工作原理,请纠正我.如果正确,那是否意味着我们只担心VM中的分配是否连续?

I was reading up on Virtual Memory and from what I understand is that each process has its own VM table that maps VM addresses to Physical Addresses in real memory. So if a process allocated objects continuously they can potentially be stored in completely different places in Physical Memory. My question is that if I allocate and array which is supposed to be stored in a contiguous block of memory and if the size of the array requires more space than one page can provide, from what I understand is that array will be stored contiguously in VM but possibly in completely different location in PM. Is this correct? please correct me if I misunderstood how VM works. And if it is correct does that mean we are only concerned whether allocation is contiguous in VM?

推荐答案

在现代内存处理程序中,在物理内存中是否确实存在与页面边界重叠的内容实际上是连续的.内存粘合逻辑本质上将所有可寻址的内存页面视为无序集合,并且该排序实质上与进程相关联;对于最终为不同的进程分配了相同的两个物理内存页(在不同的时间点),不能保证这些物理页之间的表达关系是相同的.实际上,CPU和内存之间有一个转换层来处理这些东西.

Whether or not something that overlaps a page boundary is actually contiguous in Physical Memory is never really knowable with modern memory handlers. Memory glue logic essentially treats all addressable memory pages as an unordered set, and the ordering is essentially associated with a process; there's no guarantee that for different processes that end up getting assigned the same two physical memory pages (at different points in time) that the expressed relationship between those physical pages will be the same. Effectively, there's a translation layer between the CPU and the memory that handles this stuff.

这篇关于连续的内存和VM块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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