消息队列在Linux中过时了吗? [英] Are message queues obsolete in linux?

查看:655
本文介绍了消息队列在Linux中过时了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在Linux中一直在使用消息队列(系统V,但是POSIX也可以),它们对于我的应用程序来说似乎很完美,但是在阅读了《 Unix编程的艺术》之后,我不确定它们是否真的一个不错的选择.

I've been playing with message queues (System V, but POSIX should be ok too) in Linux recently and they seem perfect for my application, but after reading The Art of Unix Programming I'm not sure if they are really a good choice.

http://www.faqs.org/docs/artu/ch07s02. html#id2922148

System V IPC的上层消息传递层已大大停用.在需要执行互斥锁定和在同一台计算机上运行的进程之间进行一些全局数据共享的情况下,由共享内存和信号量组成的较低层仍然具有重要的应用程序.这些System V共享内存功能演变为POSIX共享内存API,在Linux,BSD,MacOS X和Windows下受支持,但经典MacOS不支持.

The upper, message-passing layer of System V IPC has largely fallen out of use. The lower layer, which consists of shared memory and semaphores, still has significant applications under circumstances in which one needs to do mutual-exclusion locking and some global data sharing among processes running on the same machine. These System V shared memory facilities evolved into the POSIX shared-memory API, supported under Linux, the BSDs, MacOS X and Windows, but not classic MacOS.

http://www.faqs.org/docs/artu/ch07s03. html#id2923376

System V IPC设施存在于Linux和其他现代Unix中.但是,由于它们是传统功能,因此并不经常使用.从2003年中期开始,Linux版本仍存在错误.似乎没有人足够在意修复它们.

The System V IPC facilities are present in Linux and other modern Unixes. However, as they are a legacy feature, they are not exercised very often. The Linux version is still known to have bugs as of mid-2003. Nobody seems to care enough to fix them.

在最近的Linux版本中,System V消息队列是否仍然存在错误?我不确定作者是否认为POSIX消息队列应该正常?

Are the System V message queues still buggy in more recent Linux versions? I'm not sure if the author means that POSIX message queues should be ok?

似乎套接字几乎是所有内容(?)的首选IPC,但是我看不到用套接字或其他方法实现消息队列是多么简单.还是我想得太复杂了?

It seems that sockets are the preferred IPC for almost anything(?), but I cannot see how it would be very simple to implement message queues with sockets or something else. Or am I thinking too complexly?

我不知道与嵌入式Linux合作是否有意义?

I don't know if it's relevant that I'm working with embedded Linux?

推荐答案

我个人非常喜欢消息队列,并认为它们可以说是unix世界中使用率最低的IPC.它们快速且易于使用.

Personally I am quite fond of message queues and think they are arguably the most under-utilized IPC in the unix world. They are fast and easy to use.

一些想法:

  • 其中一些只是时尚.旧事物再次变得新.在消息队列上添加一个闪亮的爸爸,它们可能是明年的最新和最热门的事情.使用单独的进程而不是其标签的线程来查看Google的Chrome.突然,人们为一个选项卡锁定而无法关闭整个浏览器感到兴奋.

  • Some of this is just fashion. Old things become new again. Add a shiny do-dad on message queues and they may be next year's newest and hottest thing. Look at Google's Chrome using separate processes instead of threads for its tabs. Suddenly people are thrilled that when one tab locks up it doesn't bring down the entire browser.

共享内存具有类似He-man的光环.如果您没有挤掉机器的最后一个循环,并且MQ的效率稍低,那么您不是一个真正的"程序员.对于许多(即使不是大多数)应用程序来说,这完全是胡说八道,但有时一旦掌握就很难打破思维定势.

Shared memory has something of a He-man halo about it. You're not a "real" programmer if you aren't squeezing that last cycle out of the machine and MQs are marginally less efficient. For many, if not most apps, it is utter nonsense but sometimes it is hard to break a mindset once it takes hold.

MQ确实不适用于具有无限制数据的应用程序.诸如管道或套接字之类的面向流的机制更易于使用.

MQs really aren't appropriate for applications with unbounded data. Stream oriented mechanisms like pipes or sockets are just easier to use for that.

System V变体的确不受欢迎.通常,请尽可能使用POSIX版本的IPC.

The System V variants really have fallen out of favor. As a general rule go with POSIX versions of IPC when you can.

这篇关于消息队列在Linux中过时了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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