进程间通信和协作进程

发布于 2024-10-08 19:55:37 字数 168 浏览 4 评论 0原文

对于协作进程之间的数据传输和信息,我有两种解决方案: 消息传递共享内存

1-但我不知道哪一种适合低(小)数据交换,为什么?

2- 哪种实现方式更容易在计算机之间进行通信?

3-哪一个更快?为什么?

I have two solutions for data transfer and information between co-operate processes:
Message Passing and Shared Memory.

1- But I do not know which one is suitable for low(small) data exchange, and why?

2- Implementation which is easier to communicate between computers?

3- Which one is faster? And why?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

九八野马 2024-10-15 19:55:37

以下是我希望对您有所帮助的答案:

1)我建议使用“消息传递”进行小型数据交换。使用消息传递,您可以避免在共享内存中必须面对的所有问题,例如锁定、同步等。

2)您无法跨计算机实现共享内存,因此您必须使用消息传递。使用 TCP 套接字(甚至 UDP 套接字)、命名管道等。

3)如果您比较两者,则共享内存速度很快,因为数据不会像在消息传递中那样在进程之间复制,但我建议您不要选择消息传递上的共享内存只是因为“更快”,因为消息传递还有其他方面,例如简单性,避免所有锁定问题

Below are the answers which I hope helps you out:

1) I would suggest to go with "Message Passing" for small data exchange. Using Message passing you can avoid all the problems that you have to face in shared memory like locking, synchronization etc.

2) Well you can't implement Shared memory across computers, hence you have to go with message passing. Using TCP sockets (even UDP sockets), Named pipes etc.

3) If you compare both than Shared memory is fast as the data is not copied between the processes as it is being done in Message passing, but I would suggest you to not choose Shared memory over message passing just on the fact of being "faster" as there are other aspects which are on the side of message passing like simplicity, avoid all locking problems

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文