系统V IPC与POSIX IPC [英] System V IPC vs POSIX IPC

查看:191
本文介绍了系统V IPC与POSIX IPC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. System V IPCPOSIX IPC有什么区别?
  2. 我们为什么有两个标准?
  3. 如何确定要使用的IPC功能?
  1. What are the differences between System V IPC and POSIX IPC ?
  2. Why do we have two standards ?
  3. How to decide which IPC functions to use ?

推荐答案

两者都具有相同的基本工具-信号量,共享内存和消息队列.它们提供的界面与这些工具略有不同,但是基本概念相同.一个显着的区别是POSIX为Sys V提供的消息队列提供了一些通知功能. (请参见mq_notify().)

Both have the same basic tools -- semaphores, shared memory and message queues. They offer a slightly different interface to those tools, but the basic concepts are the same. One notable difference is that POSIX offers some notification features for message queues that Sys V does not. (See mq_notify().)

Sys V IPC已经存在了很长时间,这有一些实际意义-

Sys V IPC has been around for longer which has a couple of practical implications --

首先,POSIX IPC的实施范围较广.我为POSIX IPC编写了Python包装器,并且其文档列出了我对各种平台上POSIX IPC实现的了解.

First, POSIX IPC is less widely implemented. I wrote a Python wrapper for POSIX IPC and its documentation lists what I know about POSIX IPC implementations on various platforms.

在该文档中列出的所有平台上,Sys V IPC都是完全实现的AFAIK,而您可以看到POSIX IPC不是.

On all of the platforms listed in that documentation, Sys V IPC is completely implemented AFAIK, whereas you can see the POSIX IPC is not.

其相对年龄的第二个含义是POSIX IPC是在Sys V IPC使用了一段时间之后才设计的.因此,POSIX API的设计者能够从Sys V API的优缺点中学习.因此,POSIX API更简单 并且更易于使用IMO,我建议通过Sys V API使用它.

The second implication of their relative age is that POSIX IPC was designed after Sys V IPC had been used for a while. Therefore, the designers of the POSIX API were able to learn from the strengths and weaknesses of the Sys V API. As a result the POSIX API is simpler and easier to use IMO, and I recommend it over the Sys V API.

我应该注意,我从未进行过任何性能测试来比较两者.我认为较旧的API(Sys V)会花更多时间 进行性能调整,但这只是推测,当然不能替代实际测试.

I should note that I've never run any performance tests to compare the two. I would think that the older API (Sys V) would have had more time to be performance tuned, but that's just speculation which is of course no substitute for real-world testing.

为什么有两个标准-POSIX创建了他们的标准,因为他们认为这是对Sys V标准的改进.但是,如果每个人都同意POSIX IPC更好,那么许多程序仍将使用Sys V IPC,将它们全部移植到POSIX IPC将花费数年的时间.在实践中,这样做是不值得的,因此,即使到明天为止所有新代码都使用POSIX IPC,Sys V IPC仍会存在很多年.

As to why there are two standards -- POSIX created their standard because they thought it was an improvement on the Sys V standard. But if everyone agreed that POSIX IPC is better, many many many programs still use Sys V IPC and it would take years to port them all to POSIX IPC. In practice, it would not be worth the effort so even if all new code used POSIX IPC as of tomorrow, Sys V IPC would stick around for many years.

在不了解您打算做什么的情况下,我们无法告诉您应该使用哪个选项,但是您在此处获得的答案应该可以为您提供足够的信息,以便您自行决定.

We can't tell you which you should use without knowing a lot more about what you intend to do, but the answers you have here should give you enough information to decide on your own.

这篇关于系统V IPC与POSIX IPC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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