C++:Boost:托管共享内存是否需要信号量锁?
C++:Boost: Does Managed Shared Memory Require a Semaphore lock?
我有两个进程共享一个字符串向量。
- 进程 A 只会将字符串压入向量
- 进程 B 将读取字符串并将其从向量中删除
这是否需要信号量以防止数据损坏? boost 是否已使用 managed_shared_memory
处理此问题?
谢谢
据我所知,boost 可以处理它。 This page should have all the information you need
"Boost.Interprocess offers managed shared memory between processes using managed_shared_memory or managed_mapped_file. Two processes just map the same the memory mappable resource and read from and write to that object."
Boost 托管共享内存确实需要信号量锁,否则进程可以读取和写入错误数据,并且会发生意外行为。 (分段错误或其他)。
我有两个进程共享一个字符串向量。
- 进程 A 只会将字符串压入向量
- 进程 B 将读取字符串并将其从向量中删除
这是否需要信号量以防止数据损坏? boost 是否已使用 managed_shared_memory
处理此问题?
谢谢
据我所知,boost 可以处理它。 This page should have all the information you need
"Boost.Interprocess offers managed shared memory between processes using managed_shared_memory or managed_mapped_file. Two processes just map the same the memory mappable resource and read from and write to that object."
Boost 托管共享内存确实需要信号量锁,否则进程可以读取和写入错误数据,并且会发生意外行为。 (分段错误或其他)。