如何选择一个固定的地址MMAP? [英] How do I choose a fixed address for mmap?

查看:214
本文介绍了如何选择一个固定的地址MMAP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的mmap()可任选地用一个固定的位置来放置地图提供。我想一个mmap的文件,然后把它提供给在每个程序相同的虚拟地址的几个不同的程序。我不在乎的地址是什么,就像只要它们都使用相同的地址。如果需要的话,该地址可通过其中的一个在运行时选择(以及通过其他方式与其他连通)。

mmap() can be optionally supplied with a fixed location to place the map. I would like to mmap a file and then have it available to a few different programs at the same virtual address in each program. I don't care what the address is, just as long as they all use the same address. If need be, the address can be chosen by one of them at run time (and communicated with the others via some other means).

是否有Linux的保证为未使用(应用程序和内核),我可以映射到内存区域?我怎样才能找到一个地址,该地址可在多个运行的应用程序?

Is there an area of memory that Linux guarantees to be unused (by the application and by the kernel) that I can map to? How can I find one address that is available in several running applications?

推荐答案

不是真的,没有。随着现代Linux系统上的地址空间随机化就很难保证约可以或不可以使用什么解决什么。

Not really, no. With address space randomisation on modern linux systems it is very hard to guarantee anything about what addresses may or may not be used.

另外,如果你想使用 MAP_FIXED 然后要知道,你需要非常小心,因为它会导致mmap将取消映射任何可能已经处于被映射该地址通常是一个非常糟糕的事情。

Also, if you're thinking of using MAP_FIXED then be aware that you need to be very careful as it will cause mmap to unmap anything that may already be mapped at that address which is generally a very bad thing.

我真的觉得你需要找到另一种解决问题的方法...

I really think you will need to find another solution to your problem...

这篇关于如何选择一个固定的地址MMAP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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