开发者

Sharing memory-mapped files between 32 bit and 64 bit processes

开发者 https://www.devze.com 2023-01-24 03:55 出处:网络
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.

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 gi开发者_开发技巧ven flags?

Thanks


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消