D-bus

from Wikipedia, the free encyclopedia
D-bus
Basic data

developer D-Bus team
Current  version 1.12.16
( June 9, 2019 )
operating system Unix , Linux , Windows
programming language C ++
category Program library , daemon , framework
License GPL or Academic Free License
German speaking Yes
freedesktop.org/Software/dbus

D-Bus (from English Desktop-Bus ) is a free program library for interprocess communication . It is particularly geared towards the needs of desktop environments .

It is part of the freedesktop.org project and is used in almost every modern Linux distribution . In its entirety, D-Bus with all its components generally represents a lightweight middleware ( daemon to support interprocess communication) and in particular an Object Request Broker (ORB; a kind of communication broker for objects).

Basics

A simplified communication scheme: A file browser receives notification from a hardware monitoring program that new hardware has been connected

Programs can communicate with each other via D-Bus. In the example shown on the right, a file manager logs on to a system-wide program that provides information about the hardware connected to the computer (in this example the hardware abstraction layer - daemon , or hal daemon for short ). The hal daemon now informs the file manager of changes to the hardware. B. when inserting a USB stick it can automatically attach and display the contents.

functionality

Individual programs are given the opportunity to contact each other in pairs and exchange messages via the libdbus program library . Objects are addressed whose names are reminiscent of file system paths, for example /org/kde/kspread/sheets/3/cells/4/5. To ensure that different programs can be distinguished, the D-Bus objects are grouped together in a namespace . These namespaces usually contain the domains of the developers (for example /org/kdefor the programs of kde.org).

There is also an executable message bus daemon dbus with which several applications can connect. The daemon can forward messages from one application to one or more applications.

D-Bus is intended for communication between desktop applications in the same session (the so-called session bus) and for communication between the desktop session and parts of the operating system such as the kernel , the various system daemons or system processes ( system bus).

history

Even before freedesktop.org introduced a standardized messaging system for desktop applications , the two most popular desktop environments, KDE and Gnome , used different, mutually incompatible implementations of the same concept, namely DCOP ( Desktop Communication Protocol ) for KDE and a CORBA- like one Architecture ( Common Object Request Broker Architecture ) for GNOME.

D-Bus has more functions and was quickly adopted by the desktop environment projects after standardization and the implementations of the company's own systems were dropped in favor of the standard. The standard protocol has thus become a decisive factor for the Linux desktop, as the discrepancies between the user interfaces are increasingly falling.

Components

The D-Bus specification consists of three parts, namely the D-Bus daemon, the D-Bus library libdbus and the actual D-Bus protocol .

D-Bus daemon

The D-Bus daemon implements a so-called message bus , the function of which is equivalent to an Object Request Broker . Any number of clients connect to the daemon , based on the D-Bus protocol and usually with the help of libdbus . Individual (L) RPC calls are accepted by the daemon and sent to the responsible client, so the daemon is a broker. The (L) RPC calls act on abstract objects and represent method calls based on the OOP object model. The daemon also offers services such as activation . Finally, the daemon naturally provides one-to-many communication ( broadcast ) based on the individual connections.

D-bus library (libdbus)

The D-Bus library is a reference implementation of the D-Bus protocol or the D-Bus specification as a whole. It offers an API in the C programming language , with which two processes can establish a connection in order to then use LRPC / Communicate RPC. It also provides the necessary marshaling , i.e. the alignment and correct arrangement of the bytes for transport. Ultimately, the API offers all the services for a simply abstracted point-to-point (process-to-process) interprocess communication.

Based on libdbus , implementations for all common programming languages and frameworks have been developed, in the latter case in particular implementations tailored to Qt and GLib ( GTK + ). So used Gnome GDBus and KDE4 QtDBus.

D-bus protocol

The D-Bus protocol is a binary IPC protocol. Primitive types as well as permitted message types and the coding for the transport are specified. The protocol is basically based on the principle of message exchange and specifies remote calls (LRPCs / RPCs ) based on it.

Kdbus, bus1 and dbus brokers

Dbus is functionally limited and slower than alternative approaches for interprocess communication, which is why Android, for example, relies on its own Binder system instead of Dbus . To fix this, Greg Kroah-Hartman and other Linux developers developed Kdbus ( Kernel D-Bus ), a D-Bus implementation for the Linux kernel . Kdbus is significantly faster than the previous userspace solution. In addition, thanks to the more efficient architecture (≤ 2 instead of 10 copies), large amounts of data (in the GiB range) can be exchanged between processes. However, Kdbus failed for technical reasons and was not included in the Linux kernel. Bus1 was proposed as a new alternative in August 2016. In August 2017, the same developers proposed a third approach to solving the problems of dbus, dbus-broker, which should be compatible with the DBus specification.

Web links

Individual evidence

  1. Release 1.12.16 . June 9, 2019 (accessed August 5, 2019).
  2. Thorsten Leemhuis: Kdbus: New interprocess communication for the Linux kernel. Heise , January 20, 2014, accessed May 26, 2015 .
  3. Presentation slides Anatomy of kdbus (English; PDF; 250 kB) - Lennart Poettering , February 2014
  4. Presentation slides kdbus in Tizen 3.0 (English; PDF; 2.1 MB) - see comparison under D-Bus vs kdbus on page 7; 2014
  5. Bus1: New interprocess communication system for Linux presented . In: Pro-Linux . August 18, 2016 ( pro-linux.de ).
  6. dbus-broker reinvents DBus . In: Pro-Linux . August 24, 2017 ( pro-linux.de ).