针对不同系统使用IPC

发布于 2024-09-24 03:53:12 字数 92 浏览 0 评论 0原文

你好,

我在最近的一次采访中被问到这个问题,但我没有回答,因为我对 IPC 还比较陌生。

如果进程位于不同的系统上,您将如何使用 IPC?

Hii ,

I was asked this question in a recent interview for which i didnt answer as i was relatively new to IPC .

How would you use IPC if the processes are on different systems ?

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

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

发布评论

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

评论(3

何以畏孤独 2024-10-01 03:53:12

IPC 就是进程间通信的意思。进程通信的方式有很多种,两个进程是否位于同一台机器本地并没有什么区别。

如果您正在跨机器进行通信,则某些形式不可用,例如共享内存、信号、管道、内存映射文件或信号量。 (如果你真的想走这条路,有可以模拟共享内存的中间件)。

一些更常见的方法是:

文件大多数操作系统。
信号 大多数操作系统;某些系统(例如 Windows)仅在 C 运行时库中实现信号,并且实际上并不提供对其用作 IPC 技术的支持。
Socket 大多数操作系统。
消息队列 大多数操作系统。
管道 所有 POSIX 系统、Windows。
命名管道 所有 POSIX 系统、Windows。
信号量 所有 POSIX 系统、Windows。
共享内存 所有 POSIX 系统、Windows。
消息传递
(不共享任何内容)用于 MPI 范例、Java RMI、CORBA、MSMQ、MailSlots 等。
内存映射文件 所有 POSIX 系统、Windows。如果使用临时文件,此技术可能会带来竞争条件风险。

编辑:此列表取自维基百科。这份清单和任何清单一样好。

IPC just means Inter Process Communications. There are many ways for processes to communicate, There really is no difference if two processes are local to the same machine or not.

If you are talking across machines, some forms are not available to you such as Shared Memory, Signal, Pipe, Memory mapped File or Semaphore. (There is middleware that can simulate shared memory if you really want to go that route).

Some of the more common methods are:

File Most operating systems.
Signal Most operating systems; some systems, such as Windows, only implement signals in the C run-time library and do not actually provide support for their use as an IPC technique.
Socket Most operating systems.
Message queue Most operating systems.
Pipe All POSIX systems, Windows.
Named pipe All POSIX systems, Windows.
Semaphore All POSIX systems, Windows.
Shared memory All POSIX systems, Windows.
Message passing
(shared nothing) Used in MPI paradigm, Java RMI, CORBA, MSMQ, MailSlots and others.
Memory-mapped file All POSIX systems, Windows. This technique may carry race condition risk if a temporary file is used.

Edit: This list is taken from Wikipedia. The list is as good as any.

奢欲 2024-10-01 03:53:12

IPC 是一个抽象术语,表示驻留在相同或不同系统上的进程之间的任何进程间通信。

如果您在不同的系统上有进程,最明显的是基于 TCP 的通信,包括使用 TCP 作为传输的 IPC 工具。但当然这不是交换信息的唯一方式。

IPC is an abstract term which denotes any interprocess communication between processes residing on the same or different systems.

If you have processes on different systems, most obvious are TCP-based communications, including IPC tools that use TCP as a transport. But of course this is not the only way to exchange information.

孤独岁月 2024-10-01 03:53:12

IPC 是进程间通信,更多的是一种在一台机器内的不同进程之间共享数据的技术,通过这种方式,数据传递绑定了不同进程的耦合。

  • 第一种是使用内存映射技术,创建内存映射,其他人打开内存映射进行读/写...
  • 第二种是使用套接字相互通信...这具有很高的开销,因为每个进程都必须打开套接字,进行通信...虽然有效
  • 第三,是使用管道或命名管道,可以找到一个很好的例子 此处

存在一些复杂情况,例如如果一个进程用一种语言编写,而另一个进程用另一种语言编写,该怎么办,如何保证数据流兼容各个进程读取,可以使用Google的Protocol Buffer来处理 这个,有一个 .NET 版本可用,此处

虽然 IPC 机制在不同程度上是透明的并且仅在一个域内工作,例如 Windows 到 Windows、Linux 到 Linux,但您也许能够在 Windows 到 Linux 中实现这一点,反之亦然,但必须注意,因为 API 差异和功能决定了数据传输编码方案协议的结果。

IPC is Inter Process Communication, more of a technique to share data across different processes within one machine, in such a way that data passing binds the coupling of different processes.

  • The first, is using memory mapping techniques, where a memory map is created, and others open the memory map for reading/writing...
  • The second is, using sockets, to communicate with one another...this has a high overhead, as each process would have to open up the socket, communicate across... although effective
  • The third, is to use a pipe or a named pipe, a very good example can be found here

There are complications, such as what if one process is written in one language, and the other process written in another, how do you guarantee the data flow is compatible for each process to read, you could use Google's Protocol Buffer to handle this, there is a .NET version available, here.

Although to a varying degree, IPC mechanisms are only transparent and work within the one domain, such as Windows to Windows, Linux to Linux, you may be able to do so with a Windows to Linux or vice versa, although caution must be heeded, as API differences and functionalities dictate the outcome to an agreement of data transfer encoding scheme.

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