简体   繁体   English

如何确定Linux中是否未分配特定的内存位置

[英]How to determine if specific memory locations are unallocated in Linux

I am trying to determine whether a group of contiguous memory locations on my Linux system are currently holding data for a process. 我试图确定我的Linux系统上是否有一组连续的内存位置当前正在保存进程的数据。 If they are not then I want to allocate these locations to my programme and ensure that other processes know that those memory locations are reserved for my programme. 如果不是,那么我想将这些位置分配给我的程序,并确保其他进程知道这些内存位置是为我的程序保留的。

I need to access a specific memory location, eg 0xF0A35194. 我需要访问特定的内存位置,例如0xF0A35194。 Any old location will not do. 任何旧的位置都不会。

I have been searching for solutions but have not been brave enough to execute and test any code for fear that I will destroy my system. 我一直在寻找解决方案,但还不够勇敢地执行和测试任何代码,以免担心会破坏我的系统。

I do not want to run this code in kernel-space so a user-space solution is preferable. 我不想在内核空间中运行此代码,因此最好使用用户空间解决方案。

Any help would be greatly appreciated! 任何帮助将不胜感激!

There are a lot of issues at play here. 这里有很多问题。 To start, each process has its own memory address space. 首先,每个进程都有其自己的内存地址空间。 Even if a particular memory address is allocated for one process, it won't be for a different process. 即使为一个进程分配了特定的内存地址,也不会为另一个进程分配内存地址。 Memory virtualize and paging is a complex and opaque abstraction that can't be broken from within user space. 内存虚拟化和分页是一个复杂且不透明的抽象,不能从用户空间中破坏。

Next, the only reason that I can imagine you want to do something like this is to go hunting for particular DMA ranges for devices. 接下来,我可以想象您想要做这样的事情的唯一原因是寻找设备的特定DMA范围。 That is also not allowed from user space and there are much better ways to accomplish that. 用户空间也不允许这样做,并且有很多更好的方法可以实现。

If you can post what you are trying to achieve more directly, we can provide a better solution. 如果您可以直接发布想要达到的目标,我们可以提供更好的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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