我如何mmap一个_particular_区域在内存? [英] How do I mmap a _particular_ region in memory?

查看:126
本文介绍了我如何mmap一个_particular_区域在内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序。我希望它能够在不同的运行中mmap一个特定的内存区域。


  1. 我有程序的源代码。 C / C ++

  2. 我控制程序的编译方式。 gcc

  3. 我控制程序如何链接。 gcc

  4. 我控制程式如何执行(Linux)。

有这个特定的内存区域,例如0xabcdabcd到0xdeadbeef,我mmap到一个特定的文件。有没有保证这一点?



编辑:

解决方案

我如何确认没有其他任何内容?不能确保没有其他东西需要那个区域的记忆 - 先来,先服务。但是,因为你需要一个特定的内存,我猜你有一个非常专业的环境,所以你只需要确保你是第一个(使用开始脚本)


I have a program. I want it to be able to mmap a particular region of memory over different runs.

  1. I have the source code of the program. C/C++
  2. I control how the program is compiled. gcc
  3. I control how the program is linked. gcc
  4. I control how the program is run (Linux).

I just want to have this particular region of memory, say 0xabcdabcd to 0xdeadbeef that I mmap to a particular file. Is there anyway to guarantee this? (I have to somehow make sure that other things aren't loaded into this particular region).

EDIT:

How do I make sure that nothing else takes this particular region in memory?

解决方案

You cannot make sure that nothing else takes that area of memory - first come, first served. However, as you need a particular part of the memory, I'm guessing that you have a pretty specialized environment, so you simply need to make sure that you are first (using start scripts)

这篇关于我如何mmap一个_particular_区域在内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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