进程间通信和协作进程
对于协作进程之间的数据传输和信息,我有两种解决方案: 消息传递和共享内存。
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是我希望对您有所帮助的答案:
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