IPC機制學習---D-BUS

如下內容大部分是筆記。之後若是有機會接觸D-BUS,這篇文章須要改寫和完善。目前僅做一個整理吧,算是個本身一個提醒。html

Basics

a full-featured IPC and object systemreact

First, D-BUS can perform basic application IPC, allowing one process to shuttle data to another—think UNIX domain sockets on steroids. Second, D-BUS can facilitate sending events, or signals, through the system, allowing different components in the system to communicate and ultimately to integrate better. Finally, D-BUS implements a remote object system, letting one application request services and invoke methods from a different object—think CORBA without the complications. linux

First, the basic unit of IPC in D-BUS is a message, not a byte stream.session

Second, D-BUS is bus-based. D-BUS, however, provides a dæmon, known as the message bus dæmon, that routes messages between processes on a specific bus.app

A final unique feature is the creation of not one but two of these buses, the system bus and the session bus.dom

 

D-BUS supports multiple message types, such as signals, method calls, method returns and error messages.socket

 

Why D-BUS?async

These concepts make nice talk, but what is the benefit? First, the system-wide message bus is a new concept. A single bus shared by the entire system allows for propagation of events, from the kernel (see The Kernel Event Layer sidebar) to the uppermost applications on the system. Linux, with its well-defined interfaces and clear separation of layers, is not very integrated. D-BUS' system message bus improves integration without compromising fine engineering practices. Now, events such as disk full and printer queue empty or even battery power low can bubble up the system stack, available for whatever application cares, allowing the system to respond and react. The events are sent asynchronously, and without polling. ide

(以前,上層app如何監聽底層硬件的改變呢?poll一個文件,這個文件由底層kernel或者module來寫入東西,因而上層就能夠從pollwait狀態返回,獲得下層的一個通知。例如Android中的Headset Observer。如今居然能夠直接通訊!我了個擦!不過仍是要看應用場合吧。馬達馬達喲~~)spa

The Kernel Event Layer

The Kernel Event Layer is a kernel-to-user communication mechanism that uses a high-speed netlink socket to communicate asynchronously with user space. This mechanism can be tied into D-BUS, allowing the kernel to send D-BUS signals!

sysfs is an object hierarchy exported as a filesystem.

 

   

 

How to use D-BUS?

The preferred use of D-BUS is definitely using language and environment-specific bindings, both for ease of use and improved functionality. 

  

 

References

http://www.linuxjournal.com/article/7744

Linux Device Driver (bus)

http://blog.csdn.net/nero_cie/article/details/6153804

http://dbus.freedesktop.org/doc/dbus-tutorial.html

http://en.wikipedia.org/wiki/D-Bus

相關文章
相關標籤/搜索