当它的只读共享内存 [英] Shared Memory when it's for read only

查看:116
本文介绍了当它的只读共享内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读 beej的共享内存段 <指南/ p>

在最后,他说:

更常见的是,这个过程将连接到段和运行了一点,而其他项目正在改变和读取共享段。它的整洁看一个进程更新段和看到的变化出现其他进程。同样,为了简单起见,样本code不这样做,但你可以看到数据是如何独立的进程间共享。

我的问题是:它是在必要的时候共享内存是只读


解决方案

共享内存的主要目的是的进程间通信(IPC)
但是,当你做共享内存只读目的是defeated.So至少应该有一个过程,可以写进去,然后你可以只读取休息该
流程。

I am reading beej's guide for Shared Memory Segments

At the end he says:

More commonly, a process will attach to the segment and run for a bit while other programs are changing and reading the shared segment. It's neat to watch one process update the segment and see the changes appear to other processes. Again, for simplicity, the sample code doesn't do that, but you can see how the data is shared between independent processes.

My question is: it is necessary when the shared memory is for read only?

解决方案

The main purpose of shared memory is the Inter-process communication (IPC). But when you make shared memory read only the purpose is defeated.So at least there should be one process which can write into it and then you can make to READ ONLY for rest of the processes.

这篇关于当它的只读共享内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆