简体   繁体   中英

How efficient is the Linux inotify API?

I understand inotify was originally developed to facilitate certain types of filesystem management tasks like indexing, incremental backups, etc.

With that said. Is the inotify API efficient enough that it could be used as a simple but effective inter-process messaging system?

As a relative point of reference... how does it compare to something like, oh, JMS over ActiveMQ when used in this manner?

I'm not sure exactly what you had in mind with inotify but that's a bit of an abuse of what they are for and better IPC facilities exist. Message queues are hard to beat on performance and ease of use assuming you are passing bounded messages of reasonable size.

I would suggest POSIX MQs over the SysV variant sehe suggests. They have an even cleaner interface, the queues are created with a file system path entry and you don't have to mess with IPC keys; you can ls or rm a queue from the command line. They can used with select() as one more file descriptor to monitor. mq_notify() can signal or create a new thread when there is a new queue entry. They are pretty darn flexible.

If you want to do simple messaging, just use msgget , msgsnd and msgrcv ;

man mq_overview to get an introduction. This is OS builtin since kernel 2.6.6 and Glibc 2.3.4.

This is going to fly performance wise, and the interface, if anything, is ridiculously simple.


A reference example is here: http://www.cs.cf.ac.uk/Dave/C/node25.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM