A reply from Jeffery Richter

本文讨论了两个应用程序通过内存映射文件共享数据时的一致性问题。当一个应用更改并刷新内存映射文件中的值后,另一个应用是否能立即看到更新,还是需要重新打开文件才能获取最新值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  
I think I address this in the Coherence section on page 495.
But, in short, coherence is maintained between all instances of the same MMF and FlushFileBuffers does NOT have to be called. App#2 can just read the value after app #1 changes it and all is well.
 
-- Jeffrey Richter (http://Wintellect.com)
 
From: Chen, Michael
Sent: Tuesday, February 19, 2008 11:34 PM
To: Jeffrey Richter (Wintellect LLC)
Subject: Question about the memory-mapped file after reading Windows via c/c++
 
Hi Jeffrey,
 
Thanks for your another awesome version of your programming for windows series, which is Windows via c/c++.
 
After reading the contents about the chapter 17, which is about the memory-mapped file, and I’ve a instant question for you.
 
Here’s the scenario, let’s say, there’s a memory-mapped file in the disk and it contains an Integer value, 2 applications simply open it and map it into their application address respectively. If app#1 changed the value within the memory-mapped file then flushed the change into the disk file by calling FlushFileBuffer. What would happen to the view of memory-mapped file within the app#2? Can app#2 get the change immediately by re-get the value without reopen the file, or app#2 can’t be aware of the change until app#2 reopen/remaps the memory-mapped file?
 
 
Thanks,
Michael
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值