共享内存和IPC [英] Shared memory and IPC

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

问题描述

我正在读一本关于共享内存的教程,发现了如下声明:如果一个进程希望以通知新的数据已经被插入到共享内存另一个进程,它将不得不用信号,消息队列,管道,套接字或其它类型的IPC。所以什么使用共享存储器和其他类型的IPC仅通知,而不是使用一个IPC,不需要任何其它的IPC类型的主要优点是可以使用的,像消息队列和插座例如

I was reading a tutorial about shared memory and found the following statement: "If a process wishes to notify another process that new data has been inserted to the shared memory, it will have to use signals, message queues, pipes, sockets, or other types of IPC.". So what is the main advantage of using shared memory and other type of IPC for notifying only instead of using an IPC that doesn't need any other IPC type to be used, like message queue and socket for example?

推荐答案

这里的区别是对于信号与共享的状态。

信号(信号,消息队列,管道等)是适合于变短,及时,直接的信息。在这些机制的活动往往会唤醒或中断其他程序。这个比喻是,会是什么一个程序短信到另一个?

Signalling (signals, message queues, pipes, etc.) is appropriate for information that tends to be short, timely and directed. Events over these mechanisms tend to wake up or interrupt another program. The analogy would be, "what would one program SMS to another?"


  • 嘿,我添加了一个新条目哈希表!

  • 嘿,我完成了,你问我的工作要做!

  • 嘿,这里是我的猫的照片。是不是他可爱?

  • 嘿,你想出去,今晚?有这种所谓的硬盘驱动器新的地方。​​

<强>共享存储器下,与上述相比,为共享,在小部件改变或重复读相对大的,稳定的对象更有效。程序可能会请教共享内存不时或接收其他信号之后。想想,你会节目的家庭在他们家的厨房(大)白板上书写?

Shared memory, compared with the above, is more effective for sharing relatively large, stable objects that change in small parts or are read repeatedly. Programs might consult shared memory from time to time or after receiving some other signal. Consider, what would a family of programs write on a (large) whiteboard in their home's kitchen?


  • 我们最喜爱的食谱。

  • 的事情,我们知道了。

  • 我们的朋友的电话号码和其他联系信息。

  • 我们家的辉煌历史的最新手稿,监狱举办时间提供服务。

通过这些例子,你可能会说共享内存是不是严格意义上的IPC机制更接近于一个文件中,共享内存明显的例外是

With these examples, you might say that shared memory is closer to a file than to an IPC mechanism in the strictest sense, with the obvious exceptions that shared memory is


  1. 随机存取,而文件是连续的。

  2. 挥发,而文件会生存程序崩溃。

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

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