在 32 位和 64 位进程之间共享内存映射文件

发布于 2024-09-30 23:34:03 字数 475 浏览 0 评论 0原文

我的要求是在 32 位和 64 位进程之间提供共享内存文件。该文件可以由任何进程创建,具体取决于谁先来。 - 我仍然不确定这是否可能,如果可以的话,以后会有什么陷阱吗? - 从谷歌获得的一些信息: 内存映射文件 32 位应用程序只能共享映射到 32 位虚拟地址空间的内存映射文件。 64 位应用程序可以共享 32 位或 64 位虚拟地址空间中的内存映射文件。要将文件映射到可在 64 位和 32 位应用程序之间共享的内存中,64 位应用程序必须在调用 mmap(2) 时指定 MAP_ADDR32 标志和 MAP_SHARED 标志。 URL:http://docs.hp.com/en/5966-9844 /ch02s08.html#d0e3037

这是否意味着对于这种共享,内存映射文件应该由 64 位进程使用给定的标志创建?

谢谢

My requirement is to provide a shared memory file between 32 bit and 64 bit processes. This file can be created by any of the process depends upon who comes first.
- I am still not sure if this is possible and if so, any pitfalls later?
- some info got from google:
Memory-Mapped Files
32-bit applications can only share memory-mapped files that are mapped into a 32-bit virtual address space. 64-bit applications can share memory-mapped files in a 32-bit or 64-bit virtual address space. To map a file into memory that is shareable between 64-bit and 32-bit applications, your 64-bit application must specify the MAP_ADDR32 flag with the MAP_SHARED flag when invoking mmap(2).
URL: http://docs.hp.com/en/5966-9844/ch02s08.html#d0e3037

Does this means for this kind of sharing, memory mapped files should be created by 64 bit process using given flags?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫烠⑼条掵仅有一顆心 2024-10-07 23:34:03

我还没有尝试过,但我不明白为什么你不能使用 MAP_SHARED 进行 mmap,并且让它正常工作。

假设您不希望单个段对于 32 位进程的地址空间来说太大(考虑到碎片),并且您不希望它映射到两个进程中的同一地址(这可能是不可能的) ,它应该可以正常工作。

毕竟,mmap() 的效果不依赖于体系结构(仅依赖于其实现)

I haven't tried it, but I don't see why you just can't mmap with MAP_SHARED, and have it JUST WORK.

Provided you don't want a single segment which is too big for the 32-bit process's address space (bearing in mind fragmentation), and you don't want it mapped at the same address in both processes (which may not be possible), it should simply work.

After all, mmap() is not architecture dependent in its effects (only its implementation)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文