jjzjj

c++ - Windows CreateFileMapping : different file-mapping objects with same backed file

coder 2024-06-17 原文

我知道我们可以使用文件映射在两个进程之间共享内容,但这需要相同的文件映射对象。

如果每个进程使用自己的文件句柄创建自己的文件映射对象,但每个文件句柄都指向同一个文件,会发生什么情况

谢谢 张

最佳答案

来自文档:

Creating a file mapping object does not actually map the view into a process address space. The MapViewOfFile and MapViewOfFileEx functions map a view of a file into a process address space.

With one important exception, file views derived from any file mapping object that is backed by the same file are coherent or identical at a specific time. Coherency is guaranteed for views within a process and for views that are mapped by different processes.

The exception is related to remote files. Although CreateFileMapping works with remote files, it does not keep them coherent. For example, if two computers both map a file as writable, and both change the same page, each computer only sees its own writes to the page. When the data gets updated on the disk, it is not merged.

关于c++ - Windows CreateFileMapping : different file-mapping objects with same backed file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10118048/

有关c++ - Windows CreateFileMapping : different file-mapping objects with same backed file的更多相关文章

随机推荐