shm_open 和 mmap 之间的关系?

发布于 2025-01-20 03:55:27 字数 479 浏览 5 评论 0原文

我已经阅读了许多shm_open文档。所有 docs MMAP。我没有明白为什么应该与mmap一起使用? mmapshm_open做什么?文档指出:

shm_open()类似于open()。

如果这是真的,那么为什么不能直接读/写入共享内存对象,就像带有open()的常规文件一样。如果SHM_OPENMMAP应该始终一起使用,为什么他们不只是将它们合并到一个API中?

I have read many shm_open docs. All of the docs are showing how it should be used with mmap. I didn't get why it should be used with mmap? What does mmap do extra from shm_open? The docs states:

shm_open() is analogous to that of open().

If this is true, then why can't I read/write directly to the shared memory object, just like regular files with open(). If shm_open and mmap should always be used together, why they didn't just merge them into one API?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文